can't get word wrap to work on UIButton
cocoa-touch, uibutton
Solution
Try:
_continueBtn.titleLabel.numberOfLines = 0;
I've tried next code:
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(20, 20, 70, 50);
button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
button.titleLabel.textAlignment = NSTextAlignmentCenter;
[button setTitle:@"start loading"
forState:UIControlStateNormal];
[self.view addSubview:button];
It's working good for me:
Problem
I have a simple UIButton and try to get word wrap but it always shows the text in one line exceeding the button size. ``` NSString * text = NSLocalizedString(@"Start Loading",@"Start Loading"); _continueBtn.titleLabel.lineBreakMode = NSLineBreakByWordWrapping; _continueBtn.titleLabel.textAlignment = NSTextAlignmentCenter; [_continueBtn setTitle:text forState:UIControlStateNormal]; ``` Also in UI builder when I set word wrap there the text wraps - only when I run the app the text appears in one line. What have I missed here?