小编Mih*_*bar的帖子

UISegmentedControl tintColor

我在让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];
}
Run Code Online (Sandbox Code Playgroud)

如何使UISegmentedControl使用绿色色调?

cocoa-touch uisegmentedcontrol ios ios8

5
推荐指数
2
解决办法
1949
查看次数

标签 统计

cocoa-touch ×1

ios ×1

ios8 ×1

uisegmentedcontrol ×1