如何在 UISegmentedControl 中获取段的文本值?
Objective-C
NSString *title = [segment titleForSegmentAtIndex:segment.selectedSegmentIndex];
Swift:
let title = segment.titleForSegment(at: segment.selectedSegmentIndex)
[segmentedControl titleForSegmentAtIndex:int];
For the current selected index
[segmentedControl titleForSegmentAtIndex:[segmentedControl selectedSegmentIndex]];
As this is the first Google result and we are now in the swift era:
seg_ctrl.titleForSegmentAtIndex( seg_ctrl.selectedSegmentIndex)
Swift 3:
segmentedControl.titleForSegment(at: segmentedControl.selectedSegmentIndex)