IOS 7 UISegmentedControl设置色调颜色不起作用。我怎么解决呢?
这是我添加的代码:
UISegmentedControl *segmentControl = [[UISegmentedControl alloc] initWithItems:[NSMutableArray arrayWithObjects:@"YES",@"NO", nil]];
[segmentControl setTintColor:[UIColor orangeColor]];
但颜色只出现在边框,我希望它为整个背景着色。
正如我从图书馆提到的,
@property(nonatomic) UISegmentedControlStyle segmentedControlStyle NS_DEPRECATED_IOS(2_0, 7_0, "The segmentedControlStyle property no longer has any effect");*
UISegmentedControl与UINavigationBar的色调颜色有关。如果更改颜色,UISegmentedControl的色调颜色将相应更改。
[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
我想你可能想要:
[段控制设置背景颜色:[UIColor橙色]];