multiline uibutton

2019-09-22 09:20发布

How to set a multiline as title of a UIButton in iPhone programming ?

4条回答
唯我独甜
2楼-- · 2019-09-22 09:27

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/

查看更多
家丑人穷心不美
3楼-- · 2019-09-22 09:38
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.

查看更多
Evening l夕情丶
4楼-- · 2019-09-22 09:38

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

查看更多
叼着烟拽天下
5楼-- · 2019-09-22 09:53

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

查看更多
登录 后发表回答