2013-09-10 23 views
0

第一次,我決定使用NSAttributed字符串我的UILabel,歸屬的UILabel不尊重IB

不過當我把我的UILabel屬性我的標籤在IB(字體,顏色,alignement)(界面生成器界面)當我運行我的代碼的屬性從未被尊重!我必須手動添加屬性到我的標籤:

_myLabel.font = [UIFont fontWithName:@"Arial-BoldMT" size:25]; 

有人可以幫助我嗎?

回答

1

你在做什麼是運用某種字體的字體標籤的文本屬性。如果你想分配歸因文本的字體,你必須該字體指定的屬性串的屬性之一。

NSString *inputString = @"fsdfdsf"; 

NSDictionary *attributes = @{NSFontAttributeName: [UIFont fontWithName:@"Arial-BoldMT" size:25]}; 

NSAttributedString *attributecString = [[NSAttributedString alloc] initWithString:inputString attributes:attributes]; 

[_myLabel setAttributedText:attributecString]; 
+0

這是啥子我做的,但我的IB屬性不被尊重,所以我將它們中的代碼。 。 。 – JackoJack

+0

是的,我使用_label.attributedText = NSAttributedString – JackoJack

+0

@JackoJack如果設置屬性文本的標籤,以前的屬性都將丟失。您必須重新將屬性應用於字符串。 –