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
?
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 .
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)
Here's the code to do the UIButton alignment in code too: -
[myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With