Downloaded image size for UIImageView for retina vs non-retina display - ios8

I am setting UIImageView's image to a download image. I can specify the size of the image I am downloading - should I check the screen resolution and download the image at #2x or #3x size for retina display and #1x for non-retina? How do people usually handle this?
For example, if the UIImageView's size is 100x100, should I download 200x200 for iPhone 6 and 300x300 for iPhone 6s?

Related

Xcode 7.1 beta tab bar item image too big

Copied PNG image in 2x as shown.
Referred image in storyboard as shown
But display in the tab bar item is too big as shown
Can someone tell me why the image is not fitting inside the tab bar?
404x404 is too large of an image for a tab bar. The images don't scale, so you need to include the correct size image. The images need to be 30x30 points. That means 30x30 pixels for the #1x version, 60x60 pixels for the #2x version, and 90x90 for the #3x version.

manage images issue Swift

I have a problem to understand how do I manage the various image resolution in iOS with Swift.
For example if I have an image that i use it in my app , I have to create to for various devices resolution , but after that I insert in my project the various image resolution where I have to insert it, in a special folder?.
Can you help me?
You can simply drag your images with different resolutions from finder to the Asset Catalog in Xcode.
First, you need to understand why images with 1x, 2x, and 3x resolutions are needed.
Some devices' screen have denser pixels than others. These devices have what is called "Retina Displays". Imagine that you want to display a 100px by 100px image on a normal display. Now imagine that the same image is displayed on a display where the pixels are more closely packed. Obviously, the image on the second display will appear smaller. That's not a very good user experience.
To solve this problem, you can provide 2x and 3x images. The operating system will automatically choose to use these images whenever the display is a retina display.
Now let's see how you can put the images into Xcode.
First open your asset catalog:
q
Then drag the image that you want to add to this panel:
Then you will see that your image is added:
Now do you see those 1x 2x 3x thingys? That's where you need to drag the images with higher resolutions to!
So here I dragged a 2x image to the 2x slot:
Now when your app runs on a device with retina display, the 2x image will be used!
It's rather not for image resolution but screen's pixel density. Basically you've got non-retina devices (standard) and retina ( 2xstandard and 3xstandard). So, in example if you've got 100x100 point imageView that you would like to feed with image named square.png asset you will need 3 kind of images: square.png (100x100px), square#2x.png (200x200px) and square#3x.png (300x300px).
In Xcode, put these images in something called Asset Catalog - it will handle images' size managing for you.
More info: https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/_index.html

Set background image compatible for all iDevices

When creating background image for xCode project in Swift, and I also want it to be compatible for all iPhone and iPad devices, do I have to create it like i created the app icon? With all the #2x names, or do i only need 1 image?
And what size should the image be?
Since XCode 6 it's possible to use vector based graphics. This gives you the opportunity to create one vector graphic and during compilation XCode creates the necessary PNGs for iOS (actually iOS 8 does not have full support for vector based graphics).
I use Sketch 3 for creating and working with assets, so there you can create an icon (or whatever) and export it as pdf (Note you have to choose 0.5x, because this is handled in XCode as the smallest icon).
For the sizes of app icons check apple documentation, else you just use the size your imageView is
What size should the image be?
The size of your images depends on how large they are on screen. For example, say you have a UIImageView that has as width and height of 100 points:
On an iPad 2 (which doesn't have a retina display) you would be
using a 1x image and so your image file would be 100x100 pixels.
On an iPhone 5 (which uses a 2x retina display) your image file would need to be 200x200 pixels.
On an iPhone 6+ (which uses a 3x display) your image file would need to be 300x300 pixels.
When creating background image for xCode project in Swift, and I also want it to be compatible for all iPhone and iPad devices, do I have to create it like i created the app icon? With all the #2x names, or do i only need 1 image?
You should have a look at Image Sets in Asset Catalogs.
From Apple:
Image sets: Used for most types of images, an image set contains all the versions, or representations, of an image that are necessary to support various devices and scale factors.
Here's some more information on them: https://developer.apple.com/library/ios/recipes/xcode_help-image_catalog-1.0/Recipe.html
To create one:
1. Create a new file. Then go to Resource and select Asset Catalog.
2. Press Next and give your catalog a name.
3. To add an Image Set, select your Asset Catalog (the .xcassets file). Then press the plus button in the bottom left hand corner and select New Image Set.
4. You can rename the the Image Set if you want, by default its name is 'Image'. This is the name you use to reference your image in code or IB.
5. Now you've got your image set you can drag and drop images into 1x, 2x or 3x. Or you can change the Devices (in the Attributes Editor) to Device Specific and select specific screen sizes for your images.
6. Now in your code you can create a UIImage using the following:
let image = UIImage(named: "Image")
// Just replace "Image" with the name of your image set.
You have to create them in different resolutions.
For more details you can have a look:
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/IconMatrix.html#//apple_ref/doc/uid/TP40006556-CH27-SW2
You can find the right resolutions at the point: "Launch file or image"

Prevent resizing of images in ImpressPages 4.x

Whenever I add an image using the image widget in ImpressPages 4.2.5, the image is resized to the actual width of the parent container. However, as I use a responsive design, I need the image in full resolution. Otherwise, the images will look blurry on high dpi screens (e.g. Smartphones or Retina screens).
Is there a way to prevent the image widget from resizing the images?
Try to increase the image size in theme options (theme.json).
Another option is to create a new skin for that widget to output original image and not resized one. Here's an article about skins - http://www.impresspages.org/docs/widgets#skin

UINavigationBar background image for native resolution iphone 6 and 6 plus

My app has a UINavigationBar Background image that needs to alternate widths depending on iPhone screen size in play (4 inch, 4.7 inch, 5.5 inch). Is there a way to create a device specific image such as can be found in the launch screen? Right now I only see options for 1x 2x and 3x. Thanks
– (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets
Worked for me

Resources