How do I make a UISwitch under iOS 7 not take the background colour of the view behind it?

后端 未结 6 383
终归单人心
终归单人心 2021-02-02 11:27

It looks like this whenever off:

\"enter

While I\'d prefer more of a grey backgrou

6条回答
  •  梦毁少年i
    2021-02-02 12:04

    Adding to Barry Wyckoff solution : set tint color also

    UISwitch *mySwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0.0, 0.0, 51.0, 31.0)];
    mySwitch.backgroundColor = [UIColor redColor];
    mySwitch.layer.cornerRadius = 16.0; // you must import QuartzCore to do this.
    mySwitch.tintColor = [UIColor redColor];
    [self addSubview:mySwitch];
    

提交回复
热议问题