iOS7引入了一个精彩的"凸版印刷"文本效果,通过AttributedText应用于UILabel文本.我需要在简单表的单元格中具有该效果.
不幸的是,与"textLabel.text"赋值相比,它以标准方式呈现,导致了显着的滚动滞后.
似乎归因于文本渲染是非常昂贵的CPU,但iOS嵌入式应用程序如Notes滚动没有滞后.是否有可能提高渲染性能?
以下是代码示例:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyCell *cell = (MyCell*)[tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil)
{
cell = [[MyCell alloc] init];
}
NSDictionary *attrs = @{NSTextEffectAttributeName : NSTextEffectLetterpressStyle};
NSString *text = [self textWithCell:indexPath];
//next line causes lags
textLabel.attributedText = [[NSMutableAttributedString alloc] initWithString:text attributes:attrs];
//this works fine
//cell.textLabel.text = text;
}
Run Code Online (Sandbox Code Playgroud) 在WWDC 2013视频中,他们表明开发人员可以对文本使用凸版印刷效果.有没有人有任何示例代码如何使用UILabel执行此操作/如何执行此操作?