I'm currently trying to implement a UISegmentedControl that uses a different text color to the border but also spans over multi lines.
I've managed to get both work separately using this question for multiline
Two lines of text in a UISegmentedControl
for (id segment in [self.segmentedControl subviews]) {
for (id label in [segment subviews]) {
if ([label isKindOfClass:[UILabel class]]) {
UILabel *titleLabel = (UILabel *) label;
titleLabel.numberOfLines = 0;
[titleLabel setTextColor:[UIColor redColor]];
}
}
}
and using the Appearance proxy for the text color:
[ [UISegmentedControl appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor redColor]} forState:UIControlStateNormal ];
However as soon as I combine both solutions, I lose the multiline abilities! I've tried putting the code in different orders so I loop through the labels after using the appearance proxy but that doesn't work. I've also tried using a custom NSParagraphStyle with a lineBreakingMode of NSLineBreakByWorkWrapping but this doesn't work either.
Does anyone have an idea of how I could achieve this?