如何在imageView上设置自动布局约束以获得良好分辨率的图像? [英] How to set auto layout constraint on imageView for good resolution image?

查看:168
本文介绍了如何在imageView上设置自动布局约束以获得良好分辨率的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是自动布局和图像资产的新手.我对必须设置固定或根据超级视图设置的图像视图的高度和宽度感到困惑,这是否会影响分辨率.

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.

我有一个40x40的图像视图.我拥有的图片资源是1x = 72x72、2x = 96x96、3x = 144x144.我必须为所有具有良好分辨率的设备设置图像,并且根据Superview我想要宽度和高度.我必须使用什么约束?如何为所有设备获得良好的分辨率?

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?

推荐答案

只给UIViewImage这些约束:

Give only these constraints for UIViewImage:

  • 垂直居中于superView(如果需要,乘数)
  • 水平居中于superView(需要时乘数)
  • 高度wrt superView.height(约束的乘数)
  • 与自身的长宽比

  • 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

这篇关于如何在imageView上设置自动布局约束以获得良好分辨率的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆