How to set a multiline as title of a UIButton
in iPhone programming ?
-
2Agree this should be closed as a dupe. Raju - please can you try searching rather than just posting new questions. You are wasting everyone elses time. It might also help the general goodwill if you marked a few of the questions you asked as answered. – Rog Jun 08 '09 at 09:25
-
possible duplicate of [How do you add multi-line text to a UIButton?](http://stackoverflow.com/questions/604632/how-do-you-add-multi-line-text-to-a-uibutton) – phi Sep 03 '12 at 08:57
-
1Possible duplicate of [How do you add multi-line text to a UIButton?](https://stackoverflow.com/questions/604632/how-do-you-add-multi-line-text-to-a-uibutton) – Cœur Oct 16 '18 at 06:32
4 Answers
someButton.lineBreakMode = UILineBreakModeWordWrap;
Be sure to try to get in the habit of consulting the documentation before posting a question. Apple's documentation is pretty comprehensive, and things like this generally get covered.

- 6,608
- 1
- 32
- 31
-
6"Be sure to try to get in the habit of consulting the documentation before posting a question." – Carson Myers May 26 '09 at 06:41
-
2UIButton's `lineBreakMode` property is deprecated in iOS 3.0. Use `someButton.titleLabel.lineBreakMode =` instead. – titaniumdecoy Feb 28 '12 at 22:12
Hi,
There is a property of UIButton called lineBreakMode which will allow you to add multiline titles. The two main things I would set it to are UILineBreakModeWordWrap or UILineBreakModeCharacterWrap.
UILineBreakModeWordWrap wraps the last word and UILineBreakModeCharacterWrap wraps at the lastcharcter.
looks like: instanceOfUIButton.lineBreakMode = UILineBreakModeWordWrap;
or instanceOfUIButton.lineBreakMode = UILineBreakModeCharacterWrap;
hope that's what your after
Please don't use subviews.
someButton.lineBreakMode = UILineBreakModeWordWrap;
this is the right way to do this. There is a tutorial on this for the German community!
http://bedifferently.wordpress.com/2011/11/16/uibutton-bearbeite-den-titel-teil-1/
-
Please do more than just post a link; summarize the link so that this answer can stand on its own in case that link breaks. – George Stocker Nov 06 '12 at 19:25
UIButton doesn't display multiple lines. The way to make it do so is to addSubview a UILabel to the button

- 9,657
- 17
- 64
- 98