2

I am trying to left justify text on a UIButton. It is middle justified by default. The following doesnt seem to work. Can someone suggest what may work.

  aButton.titleLabel.textAlignment = UITextAlignmentLeft; 
Amarsh
  • 10,284
  • 18
  • 47
  • 76
  • Try this answer: http://stackoverflow.com/questions/2765024/how-to-set-the-title-as-left-alignment-in-the-uibutton/2765158#2765158 –  Oct 13 '10 at 12:36
  • Thanks. It works. Can you please put this in an answer so that I can acknowledge it :) – Amarsh Oct 13 '10 at 23:19

1 Answers1

4

You have to set the label alignment, not the text alignment.

aButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
antyrat
  • 26,950
  • 9
  • 73
  • 75
orkoden
  • 17,498
  • 3
  • 58
  • 50