如何在iPhone应用程序中更改分段控件中的文本颜色?

时间:2010-09-15 04:45:56

标签: iphone uisegmentedcontrol

到目前为止,我能想到的唯一解决方案是添加图像..但我想要正确的解决方案......所以我有办法改变文字/标题颜色???

2 个答案:

答案 0 :(得分:4)

使用此方法,它位于ios 5.x

UIFont *Boldfont = [UIFont systemFontOfSize:13.0f];
    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:Boldfont,UITextAttributeFont,[UIColor darkTextColor],UITextAttributeTextColor,nil];
    [self.mSegmentControl setTitleTextAttributes:attributes 
                                    forState:UIControlStateNormal];

答案 1 :(得分:0)

http://www.framewreck.net/2010/07/custom-tintcolor-for-each-segment-of.html

在这篇文章中,有一个类别的实现可以满足您的需求。

从iOS SDK中,没有方法可以直接执行此操作。

相关问题