【发布时间】:2013-05-23 22:35:55
【问题描述】:
我制作了一个 NSMutableAttributedString 对象,它由 2 个不同的 NSMutableAttributedString 对象组成:
NSMutableAttributedString * ob1 = [[NSMutableAttributedString alloc] initWithString:@"Headline"];
[ob1 addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:25.0] range:NSMakeRange(0,8)];
[ob1 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0] range:NSMakeRange(0,8)];
NSMutableAttributedString * ob2 = [[NSMutableAttributedString alloc] initWithString:@"Test"];
[ob2 addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:25.0] range:NSMakeRange(0,4)];
[ob2 addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithRed:0.3 green:0.3 blue:0.0 alpha:1.0] range:NSMakeRange(0,4)];
[ob1 appendAttributedString:ob2];
self.aUITextViewObj.attributedText = ob1;
我的问题是:文本几乎每次都在 UITextView 中准确显示。 但有时它的字体会变大。这完全是偶然的,似乎没有规律。下一次显示正确的相同文本显示太大。 我发现了什么:
- 模拟器中没有出现问题。
- 在 iPhone 4(iOS 6.1.3) 上大约 90% 的时间出现。在 iPhone 5 (iOS 6.1.4)/iPad (iOS 6.1.3) 它发生的概率约为 10%。
【问题讨论】:
-
文本中有特殊字符吗?
-
我的文本中有“元音变音”öäü(我有几个文本,它们是从表格中加载的。并非每个文本都包含äöü)但问题并没有影响它出现的文本;)
-
编辑:我忘了提及 •(项目符号)和 \n
标签: ios objective-c ios6 ios6.1