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
  • 11,214
  • 18
  • 53
  • 78
  • 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
  • 27,479
  • 9
  • 75
  • 76
orkoden
  • 18,946
  • 4
  • 59
  • 50