1

I am new in auto layouts and assets of images. I am confused that image view height and width I have to set fix or according to superview, will it effect on resolution or not.

I have a image view 40x40. And I have assets of images are 1x = 72x72, 2x = 96x96, 3x = 144x144. I have to set image for all devices with good resolution, and I want width and height according to Superview. What constraint do I have to use and how can I get good resolution for all devices?

Is Adaptive Layout necessary to use? I mean Autolayouts for Assets?

halfer
  • 19,824
  • 17
  • 99
  • 186
Kishor Pahalwani
  • 1,010
  • 1
  • 23
  • 53
  • You need to restrict the adjustment of UIImageView under 72x72 so max you can resize upto `72x72` as you have `1x` image size which usually we consider the size of UIImageView, other resolution of images are automatically selected by OS as per device to give user better image viewing but that must reside into max of 1x physical size. – iphonic Nov 23 '16 at 09:49
  • If I will give the size of imageView 72x72, It will come over the label. And constraint How to set, I mean fix height ,width or according to superView ? – Kishor Pahalwani Nov 23 '16 at 09:56
  • I am saying max you can upto 72, obviously you will adjust according to your layout, I would prefer you set it to 45 and use aspect ratio so the image icon will look bigger in bigger screens and still it will be under 72.. you can choose to fix the height and width but not recommended as it will look odd in bigger screen devices. – iphonic Nov 23 '16 at 10:00
  • Ok if I set image view size 72x72 and height width constraint fix, not according to super view then all devices get the images according to 1x, 2x, 3x ? Thanks – Kishor Pahalwani Nov 23 '16 at 10:09

1 Answers1

0

Give only these constraints for UIViewImage:

  • vertically centre to superView(Multiplier if needed)
  • horizontally centre to superView(Multiplier if needed)
  • height wrt superView.height(Multiplier for the constraint)
  • aspect ratio to itself

    enter image description here

rvx
  • 201
  • 3
  • 16