Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localizing text in a segmented controller within a XIB

I have a segment controller in a XIB with three segments, and I'd like to change the text in each segment from within code. I'm not exactly sure how to refer to individual segments from within code. Is this doable?

like image 657
Luke Avatar asked Oct 28 '25 04:10

Luke


2 Answers

UISegmentedControl includes this method:

- (void)setTitle:(NSString *)title forSegmentAtIndex:(NSUInteger)segment;

Just create an outlet from your xib onto your @interface and do:

[self.mySegmentControl setTitle:NSLocalizedString(@"something", nil) forSegmentAtIndex:0];
like image 102
Pedro Mancheno Avatar answered Oct 29 '25 20:10

Pedro Mancheno


Swift 5

**

self.segment.setTitle("Accept".localized, forSegmentAt: 0) self.segment.setTitle("Cancle".localized, forSegmentAt: 1)


**

like image 37
islam XDeveloper Avatar answered Oct 29 '25 18:10

islam XDeveloper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!