在xcode中添加UI按鈕時,我使用以下代碼來設置標題標籤的文本顏色,對齊方式和字體大小。字體大小被拾取,但不是文本顏色和對齊,爲什麼?謝謝。如何爲UIButton動態設置標籤顏色和對齊方式
toButton.titleLabel.textColor = [UIColor redColor];
toButton.titleLabel.textAlignment = UITextAlignmentRight;
toButton.titleLabel.font = [UIFont boldSystemFontOfSize:FONT_SIZE];
[toButton setTitle:fromButton.titleLabel.text forState:UIControlStateNormal];
嘗試使用setter而不是propert IES。 [toButton.titleLabel setTextColor:[UIColor redColor]] –
@ValeryPavlov Setter和屬性在運行時執行相同的代碼,沒有區別。 – Hyperbole