views:

494

answers:

3

how to set a multiline as title of a UIButton in iPhone programming

pls help me ..

thanks and regards ..

+5  A: 
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.

Matt Ball
thank you very much...have you any sample code.. pls give me...
Raju
"Be sure to try to get in the habit of consulting the documentation before posting a question."
Carson Myers
+2  A: 

hihi,

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

abe
+1  A: 

UIButton doesn't display multiple lines. The way to make it do so is to addSubview a UILabel to the button

Alexander Corotchi