Search code examples
objective-cios5uitableviewdrawrectretina-display

UITableViewCell rendering with drawRect: appears blurry on Retina iPad display


I'm using drawRect: in my UITableViewCell subclass for the rendering performance when scrolling; everything on the cell (text and graphics) is rendered in drawRect:. On the new iPad's retina display, the cell appears very blurry.

For comparison, here is a screenshot with showing both the cells (on the top) and another equally sized image on the bottom. The difference between the quality of the bottom image and of the cells is stark.

Screenshot taken on iPad with retina display

This is on a physical device, not the simulator. I've verified that the UIImage instances I'm using have a scale of 2; the user's avatar images are being loaded from the web, so it's not an issue of an @2x suffix. The "Awesome" image is the same asset loaded from the main bundle. Further, the text itself is blurry.

I've tried different options of antialiasing to no effect. I've also tried setting the contentScaleFactor of my view and the contentScale of my view's layer to [[UIScreen mainScreen] scale] but it doesn't help either.

Any suggestions?

Edit:

Here's a snippet of the drawRect: method responsible for rendering the user avatar. _avatar is an instance variable and addRoundedRectToPath() just clips a corner radius of 5 points off of the context's path.

{
    CGContextSaveGState(context);

    addRoundedRectToPath(context, avatarFrame, 5, 5);
    CGContextClip(context);

    [_avatar drawInRect:avatarFrame];

    CGContextRestoreGState(context);
}

The text of the comment is rendered in a similar way:

[[UIColor whiteColor] set];
[_body drawInRect:textRect withFont:kPXCompositePhotoCommentCellBodyFont];

I'm deploying to iOS 5.0 with a 5.1 base SDK using Xcode 4.3.2.


Solution

  • Have you set the view's layer to want rasterization? This is an opt in thing, and sometimes it's used as a trick to speed up cell performance. But improperly used it can result in ugly layers.