使用IB在UIButton上将多行文本居中 [英] Center Multi-Line Text on UIButton using IB

查看:158
本文介绍了使用IB在UIButton上将多行文本居中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用Interface Builder在UIButton中将文本逐行居中?我正在搜寻选项,只是看不到.这是按钮:

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:

推荐答案

您不能将文本设置为在笔尖居中.但是您可以在代码中更改对齐方式:

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;
}

这篇关于使用IB在UIButton上将多行文本居中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆