UISegmentedControl 改变选中字体的颜色
时间: 2024-01-21 17:04:32 浏览: 246
你可以通过设置 UISegmentedControl 的标题文本属性来改变选中字体的颜色。具体方法如下:
1. 创建一个字典,设置选中状态下的字体颜色:
```
NSDictionary *selectedAttributes = @{NSForegroundColorAttributeName: [UIColor redColor]};
```
2. 设置 UISegmentedControl 的标题文本属性:
```
[segmentedControl setTitleTextAttributes:selectedAttributes forState:UIControlStateSelected];
```
这样,当选中某个选项时,它的字体颜色就会变成红色。
阅读全文
相关推荐











