sdknewbie sdknewbie - 2 years ago 172
iOS Question

Center Multi-Line Text on UIButton using IB

How do you center text line-by-line in a UIButton using Interface Builder? I am scouring the options and just don't see it. Here's the button:

button with text not centered

Answer Source

You can't set the text to be centered in your nib. But you can change the alignment in your code:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.myButton.titleLabel.textAlignment = UITextAlignmentCenter;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download