I make a subclass of UIButton for rounded custom border:
- (void)drawRect:(CGRect)rect
{
[[self layer] setCornerRadius:CORNER_RADIUS];
[[self layer] setMasksToBounds:YES];
[[self layer] setBorderWidth:1];
[[self layer] setBorderColor:self.tintColor.CGColor];
[self.imageView setTintColor:self.tintColor];
}
The issue is when appear a popover the custom border not has the same behavior of the other control with tintColor:
How can i handle it?
Many thanks
Implement tintColorDidChange
in your UIButton subclass. iOS changes the tintColor of your button to gray, but borderColor of the layer is still the old blue color. You have to change borderColor yourself, there is no way that iOS knows that the border should be colored like your tint.
- (void)tintColorDidChange {
[super tintColorDidChange];
[self setNeedsDisplay];
}
After you used setNeedsDisplay
the system will call drawRect:
, which should update the layer color.
You could probably use this as well:
- (void)tintColorDidChange {
[super tintColorDidChange];
[[self layer] setBorderColor:self.tintColor.CGColor];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With