【发布时间】:2015-06-01 19:21:55
【问题描述】:
朋友们,
我可以在分段控件中更改分段的大小,但我需要将分段的背景颜色更改为橙色
任何详细的视图都会有所帮助
【问题讨论】:
-
见here自定义UISegmentControl
标签: ios xcode uisegmentedcontrol uicolor
朋友们,
我可以在分段控件中更改分段的大小,但我需要将分段的背景颜色更改为橙色
任何详细的视图都会有所帮助
【问题讨论】:
标签: ios xcode uisegmentedcontrol uicolor
是的……!我发现了一个开发者分析,它可以改变特定的段颜色。代码如下:
(void)setSelectedSegmentColor:(UISegmentedControl *)mySegmentedControl{
for (int i=0; i<[mySegmentedControl.subviews count]; i++)
{
if ([[mySegmentedControl.subviews objectAtIndex:i]isSelected] )
{
[[mySegmentedControl.subviews objectAtIndex:i] setTintColor: [UIColor greenColor]];
}else{
[[mySegmentedControl.subviews objectAtIndex:i] setTintColor:[UIColor redColor]];
}
}
}
欲了解更多信息,请访问此链接-http://technet.weblineindia.com/mobile/customize-or-change-color-of-selected-segment-in-uisegmentedcontrol/
我希望,这些信息将满足您的需求...!
【讨论】:
您设置分段控制 tintColor(颜色代码根据您的要求)。
segmentedControl.tintColor = [UIColor colorWithRed:.9 green:.1 blue:.1 alpha:1];
【讨论】: