【发布时间】:2015-04-26 01:08:45
【问题描述】:
我无法让 UISegmentedControl 显示所需的色调。
// AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// need red tint color in other views of the app
[[UIView appearance] setTintColor:[UIColor redColor]];
return YES;
}
// ViewController
- (void)viewDidLoad {
[super viewDidLoad];
NSArray *items = @[@"Item 1", @"Item 2"];
UISegmentedControl *control = [[UISegmentedControl alloc] initWithItems:items];
// would like to have this control to have a green tint color
control.tintColor = [UIColor greenColor];
[self.view addSubview:control];
}
如何让 UISegmentedControl 使用绿色调?
【问题讨论】:
-
你试过了吗:
[[UISegmentedControl appearance] setTintColor:[UIColor greenColor]]; -
是的,遗憾的是产生了相同的结果。
-
不是最好的方法,但可能有效。尝试为
UISegmentControl的每个子视图设置颜色?
标签: ios cocoa-touch ios8 uisegmentedcontrol