helloGo helloGo - 11 months ago 150
Objective-C Question

IOS UI Segmented Controls with an underline

I was wondering how do you do make a underline in ios segmented controls text.

Thanks

Answer Source

This SO post may help you How to create Segmented control with underline in iOS. You may be able to do it by using attributes. Something like this:

NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] init];
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:@"yourtext"
                                                                      attributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleNone)}]];
[_segmentedControl setTitleTextAttributes:attributedString  forState:UIControlStateNormal];