2

I know that in code I can do [myButton.titleLabel setTextAlignment: NSTextAlignmentRight]; but how would I do this in Storyboard in User Defined Runtime Attributes?

Apollo
  • 8,384
  • 30
  • 97
  • 186

3 Answers3

5

You can set the alignment of content (text or image) within your UIButton in the Attributes Inspector Panel.

The menu is "Control", you can set Horizontal & Vertical Alignment

Sumner Evans
  • 8,551
  • 5
  • 29
  • 46
Kakahn
  • 111
  • 6
  • How to set padding with that? I mean when i did this, the button text just sticks to the left of its view with no padding and that looks odd. – zulkarnain shah Oct 21 '17 at 07:14
2

How to make UIButton's text alignment center? Using IB

This post shows how to do it in storyboard.

enter image description here

Community
  • 1
  • 1
Max Hudson
  • 9,698
  • 14
  • 54
  • 103
0

You can also adjust the constraints of the content, title or image in the size inspector of the button:

enter image description here

In my case, I was only able to really centralize the character "+" and "-" after setting a value for the bottom of the title.

Erich Flock
  • 137
  • 1
  • 5