开发者

Aligning UIButtons/UITextFields in the center

开发者 https://www.devze.com 2023-03-18 02:53 出处:网络
I 开发者_如何转开发know that you can align UILabels in the center by typing this code: label.textAlignment = UITextAlignmentCenter

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

精彩评论

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