关闭时看起来像这样:
虽然我更喜欢灰色背景。我真的必须使用 UIImageView 吗?
以下是我更改 iOS7 UISwitch 的填充颜色的方法。
首先您需要导入 QuartzCore。
#import <QuartzCore/QuartzCore.h>
然后设置背景颜色并圆化 UISwitch 的角。
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.
[self addSubview:mySwitch];
这将为您提供一个具有自定义关闭(背景)颜色的 UISwitch。
希望这对某人有帮助:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)