colorWithPatternImage with iPhone 4 Retina Display (image@2x.png)

Deadly 提交于 2019-12-10 02:54:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!