如何更改UISegmentedControl标题颜色

时间:2012-04-19 08:27:29

标签: ios title uisegmentedcontrol

xib文件中有一个UISegmentedControl,我想在选中时更改标题颜色,怎么做?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

在(iOS 5及更高版本)中执行此操作的最简单方法是使用-setTitleTextAttributes: forState:

实施例: [segmentedControl setTitleTextAttributes:@{ UITextAttributeTextColor : [UIColor lightGrayColor] } forState:UIControlStateSelected];

文档:UISegmentedControl Class Reference