0

I have a custom class here that consists of a UIButton inside of a UIView.

The goal of this class is to allow users to have a greater area (being the UIView) to select the button than just the buttons frame itself.

Now when a user taps on the view I want the buttons highlighted image to show... But the problem is, it does not.

I've read many possible solutions to this issue For Example:

Calling: [btnObject sendActionsForControlEvents:UIControlEventTouchUpInside] This however did not change the buttons highlight.

I also tried just settings the button.highlighted = YES; But that did not work either.

I have the images for different states properly setup (Normal and Highlighted), I'm sure of that.

I also have the gestureRecognizer working properly as the functionality is great except for the lack of highlight.

Does anybody know if I'm missing any thing special that needs to be done in order to pull off this seemingly very simple task? Surely it's been done many times.

Thank you

2

2 Answers 2

0

You were on the right track. -[UIButton setHighlighted:] is just a flag. What you need to do is call setNeedsDisplay on that button right after you change the highlighted property.

0
0

I solved my problem a little while ago and I'm not sure if Kevin Low's answer would've worked too, it very well might have.

But for some reason, a UITapGesture doesn't work well with highlighting buttons as a view transitions (That might be because I didn't call setNeedsDisplay). The gesture that ended up working was the UILongPressGesture with a 0.0 sec for minimum duration.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.