3

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,874
  • 32
  • 104
  • 192

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,951
  • 5
  • 30
  • 47
Kakahn
  • 101
  • 6
  • 1
    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
4

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,961
  • 14
  • 57
  • 107
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
  • 227
  • 3
  • 6