2016-11-21 45 views
0

你好我正在使用NSMutableAttributedString在UIAlertController中顯示不同的字體,但具有相同的大小,這裏的問題是它顯示了兩種不同的字體,但它也顯示了兩種不同的大小。這裏是我的代碼NSMutableAttributeString在UIAlertController中的iOS 10.0中不起作用

UIFont *regularFont = [UIFont fontWithName:@"HelveticaNeue" size:11.0]; 
UIFont *boldFont = [UIFont fontWithName:@"HelveticaNeue-Bold" size:11.0]; 

UIAlertController *alertObj = [UIAlertController alertControllerWithTitle:nil message:messageStr preferredStyle:UIAlertControllerStyleAlert]; 

NSMutableAttributedString *attMessage = [[NSMutableAttributedString alloc] initWithString:messageStr]; 
[attMessage addAttribute:NSFontAttributeName value:regularFont range:NSRangeFromString(messageStr)]; 
[attMessage addAttribute:NSFontAttributeName value:boldFont range:NSMakeRange(25, 6)]; 
[attMessage addAttribute:NSFontAttributeName value:boldFont range:NSMakeRange(35, 15)]; 

[alertObj setValue:attMessage forKey:@"attributedMessage"]; 

結果可以match.Any幫助會的attributedMessage財產不公開,使用它可以理解

enter image description here

+0

你不應該「破解」UIAlertController。使用自定義的。 – Larme

+0

在你的範圍內給它,NSMakeRange(6,25)和NSMakeRange(15,35)。 @Nisar Ahmad – KAR

+0

問題不在範圍內。 。 。 @KAR –

回答

1

是一種在評論中拒絕您的應用的好方法。如果你真的需要風格的對話和App Store上分發的應用程序,我認爲你應該建立自己的組件來顯示彈出窗口。

相關問題