How to make image asset fit all sizes - ios

My view had a background image which was shown full screen. But I couldn't make it fit all iPhone sizes as following:
640*960, 640*1136, 750*1334, 1080*1920
I tried to differ them by name.
icon#1x.png, icon-568h#2x.png, icon-667h#2x.png, icon#3x.png
And it looks like this in Asset:
But still not working. I know it's easy for Launch Image but that image is not. Please help me with this.

Related

how to load image from camera for specific/variable sizes?

I have a very simple requirement here but I'm looking for a solution for a while. I want to take a profile picture form the camera roll or camera and display it in two different image views (different sizes). I don't want any of these images stretched or miss any part of the image. If I use aspect to fit, top side of image is cut from smaller image view and some parts missing on the bigger image view. If I set it as scale to fit, it will get stretched!
I'm not sure how some mobile apps work. Do they save different image sizes in their server or they change the size of the image. I saw many posts how to change image size without changing aspect ratio. But I don't think it is possible to avoid stretched effects. I used some of those code to change size of image, it gets stretched all the time.
Is there any way to save the image from camera roll one time with size of 140*200 and one time 160*200? So I can use 140*200 for image views that size. But what if I have different devices and different sizes.

How to include full screen image in an iOS App

I want to add a full screen image into an iOS app and I want to know the best way to support different devices
The problem with using the image assets: 1x, 2x, and 3x is that 2x is used for iPhone4s, iPhone5, and iPhone6 which every one of them has a different dimensions
Should I use a different images (one for every device) and include them as resources then at runtime I choose the image based on the current device? I feel like it is not a good solution
any suggestions of a more elegant way?
If you click on the asset you can configure more options and sizes depending on various parameters. Conceptually similar to what happens when you create a new LaunchScreen Item in the asset. See image.
Depending on what is the wanted end results you can also adopt different tactiques, like having a background image that is big enough to be set as "Center" aspect mode and the eventually place other images like logos or titles on top of it. Or again just have one big image that can be set as "AspectFit".
It's not a good idea to have a different image for every device. Either use stretching or tiling to handle different sizes, or make an image that you can clip on smaller screen sizes, or you will have to have different images for each device and code to detect which to use and spend time maintaining that whenever new devices are announced.

How to make the tabBarItem Image appear small and at the same time not let it get pixelated?

I am trying to find the ideal resolution for a tabBarItem image.
I want to keep the image small and not let it pixelate. I tried decreasing the resolution but the image became pixelated.
I tried resolution of 60x60. The tabBarItem image had clarity but the image occupied most of the tabBar.
I tried resolution of 30x30. The image rendered was of the ideal size but the image was pixelated.
What can I do to to achieve small image rendering on the tabBarItem and simultaneously stop it from getting pixelated ?
You should use image with same size that you are using in tabBarItem. You can refer Apple human interface guidelines for different image sizes you should use.
Hope this will help :)

UIImage being stretched when copying from UIPasteboard

I have a valid image with the right content size, however I have noticed when I try to paste this image to WhatsApp or through iMessage the image get's significantly stretched. I have looked at the image and it seams to be fine on UIImageview, but somehow it gets stretched in particular to outer controls.
Is there anyway to fix this issue?
When copying an image make sure to modify the imageView's mode. There are different modes, like Aspect Fit, Scale to fill and so on.
If let's say the image is 500x300 and your imageView's size is set to 350x230 and mode to Scale to fill, it will end up stretched. Try to fiddle around and see what works for you. Most of the times i choose Aspect Fit.
Try that out.
BTW. You can find it under inspection tab in design editor or set it programmatically if you choose so.

Tabbar Images Cut

I am using tabcontroller. In the first image screenshot got from storyboard, the second one got from the app on the iphone. Once you look closer to the images in the second image, you could see images are cut at the bottom compared to first screenshot tabbar images. I do not have any idea why this happened.
Make sure you use the correct names as of filename#2X.png for Retina and filename.png for non-Retina images.
Make sure you always use filename.png name convention and not the #2x in code.
Make sure you use the right dimension. My UITabBar images are some 39x48 pixels for Retina on the iPhone.
I would also advise you to convert to asset catalogs as they are enormously easy to use.

Resources