0

I dynamically created a button for my Iphone app..

All was going well until i added an image to the button and suddenly the textlabel for the button was not vertically center anymore..

The blue line in the image below represents the middle of the button.

My Problem

Anyone have any ideas on what i could do to fix this? i have tried setting the vertical alignment to center already but it did nothing.

Mattigins
  • 1,014
  • 9
  • 25

1 Answers1

0

UIButton tries to center its contents. So in this case, Image and Text are centered. However you need to player around the content inset of image and text to make it realistic center.

You can have a look at this post for further guidance.

UIButton: how to center an image and a text using imageEdgeInsets and titleEdgeInsets?

Community
  • 1
  • 1
Adil Soomro
  • 37,609
  • 9
  • 103
  • 153