开发者

Image tiles on iPhone 4

开发者 https://www.devze.com 2023-01-09 04:32 出处:网络
I am very new to iPhone development, and I am working on modifying an app which was written a year ago. Recently with the release of the new iphone 4 we have noticed that the screen which was previous

I am very new to iPhone development, and I am working on modifying an app which was written a year ago. Recently with the release of the new iphone 4 we have noticed that the screen which was previously displaying an image just fine, has not started to tile that image. And instead of one large image I am now seeing 4 smaller ones. I have tried increasing the size of this image but that does not help. Anyone know what this can be? Resolution? How do I fix this?

Th开发者_如何学Goanks, Natasha


You need to create another double-resolution version of the file with @2x in the filename. For example, if your original graphic is

tile.png

You need to create your double-resolution one as:

tile@2x.png

This will be used on the iPhone 4 and should fix your problem.

Update

If you have no control over the images you will have to detect whether you are running on a high-resolution device and set the contentScaleFactor property on the image appropriately. Something like this:

UIScreen *screen = [UIScreen mainScreen];
if ([screen respondsToSelector:@selector(scale)] &&
    [imageView respondsToSelector:@selector(setContentScaleFactor:)]) {
    /* Set image view's scale factor to that of the native screen */
    [imageView setContentScaleFactor:[screen scale]];
}

This uses an imageView, but it sounds like in your case a view is using a [UIColor colorWithPatternImage:...] on its background, so you may have to set the scale on something else. This might affect the position of subviews as well.

Why are you not able to create a new @2x version of the image and include it in your bundle?

0

精彩评论

暂无评论...
验证码 换一张
取 消