6

iOS7 introduced a wonderful "letterpress" text effect that applied via AttributedText to UILabel texts. I need to have that effect in cells of simple table.

Unfortunately being rendered in standard way it caused significant scrolling lags in compare to "textLabel.text" assignments.

Seems attributed text render is very CPU expensive, but iOS embedded apps like Notes scroll without lags. Is it possible to improve render performance?

Below is code sample:

- (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;
  }
Mix
  • 3,081
  • 2
  • 17
  • 14
  • It's not just in table view cells, even with a single label with this effect it prolongs the initialization time of a new view controller pretty significantly. Other attributed strings don't have this issue, only when using `NSTextEffectLetterpressStyle`. I'd file a bug report for really poor performance. – Jordan H May 02 '15 at 03:54

0 Answers0