您可以访问UISwitchView的onTintColor和tintColor属性.
@property(nonatomic, retain) UIColor *onTintColor
@property(nonatomic, retain) UIColor *tintColor
Run Code Online (Sandbox Code Playgroud)
初始化开关时,将onTintColor设置为On值所需的颜色,将tintColor设置为Off值.例如在UIViewController中:
UISwitch *theSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(0.0, 0.0, 41.0, 30.0)];
// on color
theSwitch.onTintColor = [UIColor blueColor];
//off color
theSwitch.tintColor = [UIColor redColor];
[self.view addSubview:theSwitch];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4029 次 |
| 最近记录: |