问题
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)?
回答1:
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];
}
来源:https://stackoverflow.com/questions/3217945/colorwithpatternimage-with-iphone-4-retina-display-image2x-png