views:

1053

answers:

1

I have the following code snippets:

@interface Foo: UIViewController { ... UIButton *myButton; ... }

@implementation Foo

  • (void) viewDidLoad { ... myButton.highlighted = YES; ... }

When I run the app, the button is highlighted in blue (default behavior). It works as I expected.

But after pressing the button once, the button is no longer highlighted.

Then, I created an IBAction highlightButton to handle "Touch Up Inside" event where I explicitly call "myButton.highlighted = Yes;". Unfortunately, the button highlight still does not stay.

How can I keep it highlighted in blue even after being pressed?

Thanks in advance for your help

A: 

See my question here.

David Kanarek
Thanks for the tip.I am not using any image. I just use text by calling "[myButton setTitle:@"Foo" forState:UIControlStateNormal]".
pion
You should be able to do this anyway. My process was to take a screenshot of a blank, **highlighted** button, and set that as the background image for the **selected** state. Then instead of changing the **highlighted** property, I changed the **selected** property. You can set the background image in Interface Builder and never worry about it again, just turn on or off the **selected** property.
David Kanarek