I’ve got a simple custom UIButton, to which I added:
button.layer.bordercolor = [[UIColor blueColor]CGColor];
However, I want to change the .bordercolor when the button is highlighted. I tried adding an action to the button’s touchDown action that changes the .bordercolor to red, but when the user lifts their finger, it stays red rather than returning to blue. Any ideas?
You were on the right track. Check the code below, it elaborates on this, but what you’ll want to do is link selectors to different control events on your button. One for
touchDownto change the shadow to red, and another fortouchUpInsideto change the shadow back when you lift your finger.Additionally, I see you’ve asked several questions on Stack Overflow and have yet to mark any as the correct answer. To continue to receive help on this website, you will need to start marking correct answers to your questions.
NOTE: Other options for
UIControlEventsinclude: