What is the best practice for supporting iOS devices of different display heights when implementing background images?
DETAIL:
I'm updating an iOS app with numerous background images. The background image used is either too short for a 4-inch display (iPhone 5) or too large for a 3.5-inch display (iPhone 4S).
Is there a way to have iOS automatically determine the correct background image to use depending on the device display height (perhaps through auto layout+constraints or image file name?) or is my only option to check the screen size in code and then apply the appropriate background image?
Are you referring to launch images? If yes, then you can define different names for different images.
If you are referring to background images for some activities, then you have a couple of options:
Create a separate background for different phone sizes and check the height of the phone in the code.
Create a background for a bigger iPhone and let the smaller iPhone to automatically crop it.
No, there is no way for phone to determine the right image resource depending on the name or the auto layout constraints.
Related
I am 2 days into iOS app development, I am quite new. The very first thing I wanted to implement in my app is a Launch Screen using Storyboards (I heard there are other ways but I found this the easier). I have a vector-based PDF file (image) because I wanted to implement a gradient background without a loss in quality that supports all device resolutions.
I created an Image View in the Interface-Builder (IB) but it does not automatically stretch vertically and horizontally to fill the device length.
I simulate my results on an iPhone 14, only thin white margins appear, but on a large iPad, the majority of the screen is white. It's like as if the the image resolution is fixed across all devices.
No matter what resizing I try, I can't get it to work.
I come from an Android app development background so something like this is very easy to implement (we have fill_parent / match_parent to stress the view to its containing parent view dimensions). Is such a behavior possible on iOS ?
You have to apply constraint on the image in launch screen.
I want have an image on my launch screen which occupies the same amount of the screen on different devices.
At the moment I have a logo which is about the right size on iPhone 4s, but on iPhone 6 Plus it's too small. Obviously these devices are in the same autolayout class.
I know I could use proportional sizing, but this will stretch the images and make them look fuzzy.
Also with it being a launch screen I can't use code for drawing or custom controls.
I guess I need some way to determine different devices in my constraints.
Add LaunchScreen asset group to your Assets. Then it will be possible to assign custom image for each screen resolution.
I created an universal iOS app. On all iPhone variants I want native resolution without scaling, so I created splash screen images for all available sizes in images.xcassets/LaunchImage.launchimage and set them all in Xcode:
Now, this works very well for all iPhone versions up to the biggest iPhone 6 Plus.
On iPad (with high pixel density) though I don't want native resolution. Instead I want it to scale the app (even if it looks a bit blurry then, but that's ok).
How would I do that?
In image assets you have to provide proper size for each launch screen, You can not use the same image for two devices in launch-images ( unless you have two copies of the same image ).
If you want to make app-size smaller, implement launch screen, set its background color to your desired background color and put your logo in the center of it. You can now remove iPhone 6,6Plus images from image assets, but you still have to provide launch images for iOS 7 devices (old iPhones / iPad ).
Don't use the Asset Catalogue. Create a LaunchScreen.xib , add a UIImage inside the view. Open the attribute inspector in the right hand panel and set the view mode to Aspect Fill.
The solution was quite easy, I simply changed project type from "universal" to "iphone" and that did the trick!
I have a graphic designer that creates images and things like that for me. Do I need give him separate image sizes to be created specifically for iPhone 5, or do I build like I used to for the 3.5 inch screen? Will the images be resized automatically?
Here is one link that may help you.
Naming convention for iPhone 5 images?
and heres another
Screen size of iphone 5
Reviewing these links basically evaluates to yes you have to create separate images for iPhone 5 you will need to add -568h#2x.png to the end of each image that is for iPhone 5. You need to also create and set the launch image as well called Default-568h#2x.png are it will not pick anything up for the iPhone 5.
No it will not resize the images automatically it will select the correct image to use, it will select the one with the -568h#2x.png simple as that.
Hope this helps.
You have to provide specific files if your images are dependent on the screen ratio.
In order to conditionally use an image according to the device you can use the technique shown here.
If that's not the case, simply provide the same images and adjust the layout programmatically or within Interface Builder.
No iOS devices with a retina display can run iOS 3. You will need high resolution versions of all your pictures.
As for converting photos to work with the iPhone 5, it depends on the photo and how it's used. If the image is used as part of the background, you have two options: you can tile it, which would not require new pictures, or you will have to redesign it altogether.
As for the other pictures, whether you can work with the same ones (same size or resized) or need new ones depends on user interface decisions only you can make. If an image must retain a certain ratio, then perhaps you can resize it and place it accordingly, or maybe an entire new image would work better.
1. What is the best way to insert a background in a xcode ios app?
2. I have two backgrounds, one big that covers it all and one smaller with some details on the bottom. Do i have to make two different pictures for the smaller background so that it fits on all iphones?
-Simon
The background picture should be on the main view and for inserting the smaller picture, use a subview. You can also popup a subview or animate it if u want to.
I think in general the best approach is to create two images that have the same content but are different in size.
You should create one image that is 320X480 for the iPhone 4 and below and one image that is 640X960 for the retina display on iPhone 4S and above. the format is:
ImageName.png (320X480)
ImageName#x2.png (640X960)
When you're referring to an image in your code you should use ImageName.png as the source image and the device will automatically decide whether to use the regular image or the retina display image.
It will be very user friendly (to say the least) to use the same content in your background whether it's an iPhone 4 and below or above.
As a side note: if you are using Cocos2d the HD image format changes to ImageName-hd.png