Select the whole UIButton, not just the image on the left side?

I have a regular UIButton with an image on the left. Show touch to highlight is enabled in storyboard, but when I touch that button, the image becomes highlighted and the text doesn't! I would like to highlight the entire UIButton.

Screenshot

+3


source to share


2 answers


Set the image as "background image" and the title as is, now select the option "Shows Touch On Highlight". Please direct this help and highlight the complete button.



-1


source


I had the same problem. A workaround is to change the title color for the selected state.

Two solutions:

1 / In the interface builder:

  • property in your UIButton property configuration condition ", select the" selected "

  • Change the text color property to the highlighted color you want.



enter image description here

2 / Programmatically:

Same ideas as above in Swift 3 :

button.setTitleColor(.black, for: .highlighted)

      

0


source







All Articles