iOS: Preparing background images for applications

2019-01-31 08:33发布

Mostly every iOS application has a view with an image as background. Is there any image sizing guide out there? For example here is an iOS screen designed in Sketch:

enter image description here

As you can see there is a background image. Now there are lots of Apple devices every application should support. The new iOS 10 supports all devices from iPhone 5 to iPhone 6s Plus. They have different screen sizes and resolutions. When creating Xcode assets, I am giving 3 background images with different sizes - @1x, @2x, @3x. What sizes should they be?

7条回答
▲ chillily
2楼-- · 2019-01-31 09:13

If you still have the same problem then you can try this one. For this you have to add only one image with good resolution and below code..

UIImage *bgImage = [UIImage imageNamed:@"art_background_star@3x.jpg"];
CGSize screenSize = [UIScreen mainScreen].bounds.size;
UIGraphicsBeginImageContextWithOptions(screenSize, NO, 0.f);
[bgImage drawInRect:CGRectMake(0.f, 0.f, screenSize.width, screenSize.height)];
UIImage * resultImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIColor *backgroundColor = [UIColor colorWithPatternImage:resultImage];
self.view.backgroundColor = backgroundColor;
查看更多
欢心
3楼-- · 2019-01-31 09:16

There is design nuance in full size background images.Mostly if scale aspect fill good enough for different sizes you need to design only biggest device size after than rest of them scale to fit as it is.Sometimes some part of background need to keep visible or purpose of keeping low memory print in small device sets you need to create smaller alternatives.

Whenever you make decision with design size of asset you need to create @3x,@2x variants.

One more thing i need to point about vector designs.if your design made only with vectors you can choose pdf vector export.Storyboard can accept vector assets and they are doing very good when scaling in full backgrounds.

查看更多
男人必须洒脱
4楼-- · 2019-01-31 09:23

The background images you only need to give are @2x and @3x, because @1x devices are now long gone in the dusty pages of history.

Speaking of @2x and @3x, the image resolutions you give to the developer should be the same with the highest resolution iPhone that uses that given size.

For @2x, that is the iPhone 6, which is 750x1334, and for @3x, the iPhone 6+ which is 1242x2208.

Down-scaling shouldn't be a problem because the aspect ratios of all iPhones that support iOS 10 are the same(16:9).

Note for Developer(s):

The UIImageView will then down-scale the images appropriately,
provided: 

1. you created an image set with the provided @2x and @3x images, 
2. correctly constrainted the UIImageView to the edges of the superview, and
3. selected the Content Mode of the UIImageView as Scale to Fill or Aspect Fill.
查看更多
爷、活的狠高调
5楼-- · 2019-01-31 09:29

The way I see it you have 2 options:

  1. In here you will find the resolutions of the iPhone's:

iphone screen resolutions

  • You don't need the @1 image since you don't support iPhone 4 and 4s (iOS 10).
  • @2 is for iPhone 5,5c,5S,6 and 6s so basically you can create @2 image of the highest resolution which is the iPhone 6 and this image will work well for the iPhone 5 family.
  • Or, you can create an image with resolution for each iPhone and using hard coded logic set the image for each phone. i.e: if iphone5c { setImage("iphone5cImage") } etc etc..

  1. The simplest solution is to create 1 image with the highest resolution. The @3 is the highest for the iPhone 6S+ and it will look amazing for the rest. Don't forget to set the image view as aspect fill.

Also, don't forget to check this thread: How to handle image scale on all the available iPhone resolutions?. It will give you clues of what exactly you are dealing with. TL;DR, It's the options I wrote.

查看更多
forever°为你锁心
6楼-- · 2019-01-31 09:29

I use background images in my Apps. To solve this problem I use one image that has the resolution to cover all iPhones and all the iPads except the large one. The image size is 2048x2048 points or 1024x1024 pixels at @2x to cover the 9.7 inch iPad.

The image is compressed JPG to keep the size down. Note that I allow it to scale for iPhone 6 Pluse (@3x) and 12.7 inch iPad Pro (@2x) as the quality doesn't seem to be affected. I can justify the scaling for the larger devices, because if I provided image for the 12.7 inch iPad Pro, it will be 5464x4096 points (@2x) and 2732x2048 pixels and then the JPG compression would have to be so high (if I wanted to keep the size down), that the quality of the image was low anyway compared with scaling.

If you need high quality try both JPG and PNG for comparison, because the PNG becomes very large for complex images, but gives the best quality.

查看更多
ゆ 、 Hurt°
7楼-- · 2019-01-31 09:29

enter image description here

There are 3 kinds of Apple Devices (iPhone and iPad) that is

Normal device which terms to 1 pixel = 1 point@1x (Older iPhone and iPad devices)

Retina device which terms to 4 pixels(2 x 2) = 1 point@2x (iPhone 5+)

Retina iPhone6 and iPad which terms to 9 pixels (3 x 3) = 1 point@3x (iPhone6+)

enter image description here

For iOs 10 that will not support iPhone 4s so you only require @2x and @3x images.

As you can see above attached image iPhone 6 also support @2x Scale so use image size for @2x is of 750*1334 and for @3x is of 1242*2208 with image mode.

查看更多
登录 后发表回答