When I set the alpha of the button it also affects the opacity of the title. Is there a way to target only the background and leave the title alpha at 1.0?
This works for me:
self.myButton.backgroundColor = [UIColor clearColor];
or if you don't want to have it completely clear, but still with transparency you can use:
self.myButton.backgroundColor = [UIColor colorWithRed:200.0/255.0 green:200.0/255.0 blue:200.0/255.0 alpha:0.5];
The second example would give you gray color with alpha 0.5.
SWIFT 4 Update
myButton.backgroundColor = .clear
OR
myButton.backgroundColor = UIColor(red: 200.0/255.0, green: 200.0/255.0, blue: 200.0/255.0, alpha:0.5)
You can also change the alpha of the color in the storyboard,
see attached image:
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