基本上ios中用到文字的空间都有属性来控制文本对其的方式的,其中UILabel的对其方式是
label1.textAlignment = UITextAlignmentCenter;
文本对齐方式有以下三种
typedef enum {
UITextAlignmentLeft = 0,左对齐
UITextAlignmentCenter,居中对齐
UITextAlignmentRight, 右对齐
} UITextAlignment;
按钮对其的方式是:
button.titleLabel.textAlignment = NSTextAlignmentCenter;
typedef enum {
UITextAlignmentLeft = 0,左对齐
UITextAlignmentCenter,居中对齐
UITextAlignmentRight, 右对齐
} UITextAlignment;