【问题标题】:How to change the font size of a single index for UISegmentedControl?如何更改 UISegmentedControl 的单个索引的字体大小?
【发布时间】:2015-08-02 14:20:35
【问题描述】:

更改UISegmentedControl 字体大小的方法如下:

UIFont *font = [UIFont systemFontOfSize:13.0f];
NSDictionary *attributes = [NSDictionary dictionaryWithObject:font forKey:UITextAttributeFont];
[self.segment setTitleTextAttributes:attributes forState:UIControlStateNormal];

如何更改UISegmentedControl 中单个索引的字体大小?或者更好的是,如果文本不适合segment(而不是“Above”,它有“Abo...”),字体大小应该更小,以便它可以适应。

【问题讨论】:

标签: ios objective-c cocoa-touch uisegmentedcontrol


【解决方案1】:

请尝试以下代码

for (UIView *v in [[[segment subviews] objectAtIndex:0] subviews]) {
    if ([v isKindOfClass:[UILabel class]]) {
        UILabel *label=(UILabel *) v ;
        lable.font=[UIFont systemFontOfSize:13.0f];
    }
}

【讨论】:

  • 是否只循环通过第一个索引? ([[segment subviews] objectAtIndex:0])
  • [[segment subviews] objectAtIndex:0] 根据您的标签索引更改 objectAtIndex
猜你喜欢
  • 2011-01-17
  • 2011-03-30
  • 2016-05-22
  • 2012-11-28
  • 2016-11-22
  • 2012-02-20
  • 1970-01-01
  • 2015-03-12
  • 2018-01-12
相关资源
最近更新 更多