问题
The way to change the font size for a UISegmentedControl
would be the following:
UIFont *font = [UIFont systemFontOfSize:13.0f];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont];
[self.segment setTitleTextAttributes:attributes forState:UIControlStateNormal];
How can I change the font size for a single index in a UISegmentedControl
? Or even better, if the text doesn't fit in the segment
(instead of "Above", it has "Abo...") the font size should be smaller so that it can fit.
回答1:
Please try with below code
for (UIView *v in [[[segment subviews] objectAtIndex:0] subviews]) {
if ([v isKindOfClass:[UILabel class]]) {
UILabel *label=(UILabel *) v ;
lable.font=[UIFont systemFontOfSize:13.0f];
}
}
来源:https://stackoverflow.com/questions/30364868/how-to-change-the-font-size-of-a-single-index-for-uisegmentedcontrol