Question

I am not a huge fan of interface builder but I am trying to create a UIButton that would highlight when touched. I was thinking the whole button to reverse. I see this property reverses on highlight but what it does is to reverse the text. I want the whole button to reverse color.

This is how I have it now:

enter image description here

This is a green button with rounded corners. Is there a way to make the whole button to reverse from interface builder?

This is an iOS 7 only project.

Was it helpful?

Solution

If you want to keep things inside interface builder, I believe your only option is to configure different background images for each button state. I had the same problem and couldn't find a way to use different UIColors for different button states. If your button style is really minimal, you could potentially use 1x1 pngs and apply rounded corners using Quartz directly in code.

In my case, I ended up creating a custom subclass of UIButton with a setter to configure different colors/text colors and shadows for each state (I used an enum to map different button "themes").

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top