设置 UISwitch 打开时的笔触颜色? [英] Set the stroke color for a UISwitch when it's on?
问题描述
我有一个 UISwitch,它需要在打开和关闭时具有相同的样式.唯一的区别是小圆圈的位置.
I have a UISwitch that needs to have the same style when it's on as when it's off. The only difference would be where the little circle is.
关闭时是这样的:
……这很好.但是当我打开它时,笔画消失了:
… which is good. But when I turn it on, the stroke disappears:
如何让它在打开时保持笔画?如果这是不可能的,我可以至少在它关闭时而不是在它打开时着色吗?
How do I make it keep the stroke when it's on? If that isn't possible, can I at least make it tinted when it's off and not just when it's on?
推荐答案
Apple 可能会拒绝您的应用程序,因为它没有为 On 状态显示不同的颜色,但是我相信这就是您想要的:这将显示 'stroke'现在每个州.
Apple may reject your app for not showing a different color for the On state, however I believe this is what you're wanting: This will show the 'stroke' for each state now.
@property (nonatomic, strong) IBOutlet UISwitch *theSwitch;
self.theSwitch.layer.borderColor = [UIColor colorWithRed:229.0/255.0 green:229.0/255.0 blue:229.0/255.0 alpha:1.0].CGColor;
self.theSwitch.layer.borderWidth = 1.5;
self.theSwitch.layer.cornerRadius = 31.0/2.0;
结果:
这篇关于设置 UISwitch 打开时的笔触颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!