How to set a multiline as title of a UIButton
in iPhone programming ?
问题:
回答1:
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.
回答2:
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
回答3:
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/
回答4:
UIButton doesn't display multiple lines. The way to make it do so is to addSubview a UILabel to the button