Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone - Image not align at center on UIButton

I have customized UIButton with the following properties:

  1. 84x44 frame
  2. 84x44 background image
  3. 32*32 image that should be centered

but my image is always aligned to the left. How can I align it back to center position on the UIButton?

I have a title on my button that is hidden (clearColor). These titles are key_value in a dictionary so I know which button is pressed and return corresponding value in the dictionary. I now understand that it's these text that is pushing my image sideway, but how do I fix that?

Under attribute inspector, there is a tap named Edge, set to Image. I set left value as 22 and all image align to center. Can someone explain to me how this works?

like image 677
Shakesbeer Avatar asked Nov 29 '22 03:11

Shakesbeer


1 Answers

Check that your titleLabel is blank - if it has text, it will push the image to the left to make room for the titleLabel on the right.

like image 195
Tim Avatar answered Dec 09 '22 17:12

Tim