更改分段控制按钮的背景颜色

change the back ground color of segmented control buttons

朋友,

我可以在分段控件中更改段的大小,但我需要将段的背景颜色更改为橙​​色

任何详细视图都会有所帮助

您设置段控件tintColor(颜色代码根据您的要求)。

segmentedControl.tintColor = [UIColor colorWithRed:.9 green:.1 blue:.1 alpha:1];

是的...!我找到了一个开发者分析,它可以改变特定的段颜色。代码如下:

(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]];
        }
    }
}

欲了解更多信息,请访问此 link- http://technet.weblineindia.com/mobile/customize-or-change-color-of-selected-segment-in-uisegmentedcontrol/

希望这些信息能满足您的需求...!