Reputation: 5804
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.
It looks like this when it's off:
… 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?
Upvotes: 1
Views: 1204
Reputation: 5902
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;
Results:
Upvotes: 6