Is there any way to change the color of a UIButton when it's pressed?
The default seems to be a blue color, but I don't see where or how to change this to a custom color.
Thanks!
If you are using storyboard then in inspector window you can change the highlight tint
property to the color you want on button click event.
Look at the Highlight Tint
property in image.
I ultimately followed the following poster's suggestion. It worked perfectly.
https://stackoverflow.com/a/10670141/720175
In my particular case I created a subclass of UIButton, with the final code as:
-(void) setHighlighted:(BOOL)highlighted
{
if(highlighted) {
self.backgroundColor = [UIColor colorWithRed:1 green:0.643 blue:0.282 alpha:1];
} else {
self.backgroundColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
}
[super setHighlighted:highlighted];
}
Easy as pie.
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