Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIButton title alignment and multiline support

How do I set the title of a UIButton to be left-aligned, and how can I show multiple lines of text in a UIButton?

like image 577
Raju Avatar asked Jun 05 '09 07:06

Raju


People also ask

How do you make a UIButton multiline?

To make a multi-line text in UIButton, you insert a new line character ( \n ) wherever you want in button title and set lineBreakMode to byWordWrapping . You can adjust text alignment with . textAlignment .

How do I change the button title color in Objective C?

You can use your custom color by using RGB method:button. setTitleColor(UIColor(displayP3Red: 0.0/255.0, green: 180.0/255.0, blue: 2.0/255.0, alpha: 1.0), for: . normal)


1 Answers

Here's the code to do the UIButton alignment in code too: -

[myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; 
like image 118
Ian Kershaw Avatar answered Oct 13 '22 13:10

Ian Kershaw