0
我需要爲UILabel
中的不同文本顯示不同的字體。如何使用不含索引的文本屬性
我知道,我們可以在一個單一的標籤中使用屬性文本管理與屬性的文本不同的字體,如下所示:
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Hello. That is a test attributed string."];
[str addAttribute:NSBackgroundColorAttributeName value:[UIColor yellowColor] range:NSMakeRange(3,5)];
[str addAttribute:NSForegroundColorAttributeName value:[UIColor greenColor] range:NSMakeRange(10,7)];
[str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:20.0] range:NSMakeRange(20, 10)];
agendaLabel.attributedText = str;
但在這裏我有一個大的數據量和這麼多的地方我有時間,我需要在字符串中加粗的時間,而不用明確地設置範圍。
上午7:00 - 上午7時15分早餐
上午7:30 - 會議12:30會議
我有很多地方像大量的數據上面。
哇,它的工作原理,謝謝 – user2732294