Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

walty

macrumors member
Original poster
Jul 15, 2008
33
0
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.

Code:
	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.
 
UIButton doesn't display multiple lines. The way to make it do so is to addSubview a UILabel to the button.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.