UITextView - 设置attributedText的字体大小慢?

时间:2013-04-29 22:45:35

标签: iphone ios objective-c ios6 uitextview

我正在尝试使用以下内容更改我的UITextView文本的字体大小(使用属性文本):

UIFont *font = [self.textView.font fontWithSize:value];
NSDictionary *attributes = @{ NSFontAttributeName: font };

NSMutableAttributedString *attrString = [self.textView.attributedText mutableCopy];
[attrString addAttributes:attributes range:NSMakeRange(0, attrString.length)];
self.textView.attributedText = attrString;

然而,将此与滑块结合使用会导致明显的减速。我这样做了吗?简单设置textView.font属性的字体大小不起作用。

这就是我首先设置属性文本的方式:

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"Neutra church-key brunch farm-to-table disrupt skateboard, bushwick next level organic gentrify street art. Pop-up echo park pork belly pour-over. Bespoke meggings put a bird on it, plaid hashtag farm-to-table YOLO freegan pug pickled jean shorts quinoa gentrify forage. Tumblr butcher echo park, small batch mumblecore banjo trust fund intelligentsia bushwick VHS raw denim."];
[string addAttribute:NSForegroundColorAttributeName value:[UIColor blueColor] range:NSMakeRange(59, 13)];
[string addAttribute:(NSString*)NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:NSUnderlineStyleSingle] range:(NSRange){59, 13}];

textView.attributedText = string;

0 个答案:

没有答案