Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

colorWithPatternImage with iPhone 4 Retina Display ([email protected])

Thanks to SO's search function blowing up whenever I enter "@2x", it's difficult to tell whether this has already been asked...

I've been using colorWithPatternImage: to build tiled background images for my various views. However, these predictably look like trash when viewed on the new iPhone 4 display. So I've built @2x versions of my tile.png files, yet colorWithPatternImage: evidently can't properly handle UIImages with double the scale.

Has anyone effectively developed a workaround for this issue? Perhaps within the CoreGraphics framework (of which, I'm quite the novice)?

like image 721
Greg Combs Avatar asked Jul 10 '10 05:07

Greg Combs


1 Answers

I believe this is a bug with the SDK. colorWithPatternImage: is doing strange things with the HD image. There's a small thread on the Apple Dev Forums on it, but basically I think it's a bug. Not sure if Apple are aware of it just yet.

I've worked around it by drawing the pattern in a subclass of the view within -drawRect:.

Hope this helps.

- (void)drawRect:(CGRect)rect {
    [[UIImage themeImageNamed:@"UIBackgroundPattern.png"] drawAsPatternInRect:rect];
}
like image 107
Michael Waterfall Avatar answered Nov 20 '22 23:11

Michael Waterfall