开发者

Aligning UIButtons/UITextFields in the center

I 开发者_如何转开发know that you can align UILabels in the center by typing this code:

label.textAlignment = UITextAlignmentCenter

Two questions: 1), how do you do the same for UIButtons and UITextFields? And 2), will these objects remain in the center after the device is rotated? Thanks for your help!


1. UIButton has UILabel inside. You can access it via titleLabel property:

button.titleLabel.textAlignment = UITextAlignmentCenter;

2. Yes, they will remain in center

3. You can find more info about UIButton in UIButton's Class Reference.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜