Android teem
Android teem

Reputation: 830

Images sizes for different screen

I have developed the IOS app, and it is my first app ever. I have 2 real devices. Iphone 5 and Iphone 6 plus.

I have created a UITable and in that under the custom cell I am showing small images let say 20 * 20 to represent something followed by its text.

For example I am using location icon and then I write its location in string. and both are horizontally aligned in a cell.

when I run it on the emulator Iphone 8, it shows the icon and the screen design is as expected. but when I run it on my both devices it is not showing me icons there it is only showing location in text form but location image is just not there in both devices.

So I know I am doing something wrong so my summed up questions are

I followed a tutorial over youtube but that was for app icon, and my app icon are visible on each devices, and looks good. But I am really confused about other icons that I have to use inside the app. and about their sizes and about how to put them in project

Please help me, and discuss it with me instead of links of pages because I have read too much on it but still a dumb head. please help me

Upvotes: 0

Views: 1335

Answers (1)

vacawama
vacawama

Reputation: 154593

Here is how to add an image to your project:

  1. In the Project Navigator, open the Assets.xcassets by double-clicking on it.
  2. Control-click in the blank area below AppIcon and select New Image Set from the pop-up.
  3. A new asset called Image will appear. Click on Image and give it the name you want to use, (for example "house").
  4. Drag and drop 2x and 3x PNG images into the appropriate spots. If your image is 20 x 20 points on screen, then your 2x image should be 40 x 40, and your 3x image should be 60 x 60. It is up to you to make sure those images have the proper detail and are not just scaled up low resolution images. (See Xcode images explanation for more background on 1x, 2x and 3x images).
  5. In your code, you can load the image with let image = UIImage(named: "house") and iOS will select the proper resolution image for your device. The iPhone 5 will use the 2x version, and the iPhone 6 Plus will use the 3x version.

Upvotes: 2

Related Questions