multiline title in uibutton

Discussion in 'iOS Programming' started by walty, Nov 4, 2008.

  1. walty macrumors member

    Jul 15, 2008

    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.

  2. PhoneyDeveloper macrumors 68040


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

Share This Page