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
財產不公開,使用它可以理解
你不應該「破解」UIAlertController。使用自定義的。 – Larme
在你的範圍內給它,NSMakeRange(6,25)和NSMakeRange(15,35)。 @Nisar Ahmad – KAR
問題不在範圍內。 。 。 @KAR –