Created
April 7, 2015 02:26
-
-
Save jaminguy/868a4a3be6a1b5f8c5f1 to your computer and use it in GitHub Desktop.
UISegmentedControl in UINavigationBar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
let segmentedControl = UISegmentedControl(items: ["Less Filling", "Tastes Great"]) | |
segmentedControl.addTarget(self, action: "segmentChanged:", forControlEvents: UIControlEvents.ValueChanged) | |
segmentedControl.selectedSegmentIndex = 0 | |
self.navigationItem.titleView = segmentedControl | |
} | |
func segmentChanged(sender: UISegmentedControl) { | |
println("\(sender.selectedSegmentIndex)") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment