PDA

View Full Version : multiline title in uibutton




walty
Nov 4, 2008, 02:42 AM
hi,

Just tried to make the title of UIButton as of multiple lines, there is a property of lineBreakMode in UIButton, but it seems does not make much effect. No matter what the break mode is set to, the size of button just varies as the length of title. Also, unlike UILabel, there is no place to set the max. number of lines allowed.


button = [UIButton buttonWithType:UIButtonTypeRoundedRect];

//same result no mater I set the background image or frame
// button.frame = CGRectMake(0, 0, 40, 100);
[button setBackgroundImage:img forState:UIControlStateNormal];

button.lineBreakMode = UILineBreakModeWordWrap;

[button setTitle:@"aaa bbbb ccc ddd" forState:UIControlStateNormal];



Did I miss something obvious here? Yet it seems there is not much related result in Google.


Thanks.



PhoneyDeveloper
Nov 4, 2008, 08:39 AM
UIButton doesn't display multiple lines. The way to make it do so is to addSubview a UILabel to the button.