更改 UISegmentedcontrol 中的文本颜色
我使用下面的代码来更改 UISegmentedcontrol 中每个分段的文本颜色,如何更改特定分段的文本颜色?(例如索引 2 处的分段)
for (id seg in [segment subviews])
for (id label in [seg subviews])
if ([label isKindOfClass:[UILabel class]])
[label setTextColor:[UIColor redColor]];
I use below code for change textcolor of each segmented in UISegmentedcontrol how can I change textcolor of specific segment?(for example segment at index 2)
for (id seg in [segment subviews])
for (id label in [seg subviews])
if ([label isKindOfClass:[UILabel class]])
[label setTextColor:[UIColor redColor]];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用下面的代码来解决这个问题
i use below code for this problem
据我所知,目前还没有基于定制的解决方案。但是您可以将图像用于必要的片段 (
setImage:forSegmentAtIndex:
) 或查看以下内容:http://matteocaldari.it/2010/05/a-uisegmentedcontrol-with -custom-color (作者对 UISegmentedControl 进行了子类化,并在重写的
drawRect:
方法中实现了自定义绘图)。As far as I know there is no customization-based solution for this. But you can either use images for necessary segments (
setImage:forSegmentAtIndex:
) or look at this:http://matteocaldari.it/2010/05/a-uisegmentedcontrol-with-custom-color (authors have subclassed UISegmentedControl & implemented custom drawing in overriden
drawRect:
method).