简体   繁体   English

如何使用自动布局管理所有iPhone尺寸的图像尺寸

[英]how to manage image size for all iphone sizes using autolayout

I am working an iOS app using autolayout.Please refer my screenshot below.I want to manage my image in all iphone and ipad(small size for iphone and big size for ipad) 我正在使用自动布局的iOS应用程序。请参阅下面的屏幕快照。我想在所有iPhone和iPad上管理我的图像(iPhone尺寸较小,iPad尺寸较大) 在此处输入图片说明 .What type of constraints i should apply. 我应该应用哪种类型的约束。

If you want the same height in all devices you can set the top, the leading and trailing constraints, then the "equal height" to the superview and change the multiplier to 0.3 like in the image: 如果要在所有设备中都设置相同的高度,则可以设置顶部约束,前导约束和尾随约束,然后将“相等高度”设置为超级视图,并将乘数更改为0.3,如图所示:

在此处输入图片说明

在此处输入图片说明 Yes, you can apply Aspect Ratio constraint to UIImageView to its own. 是的,您可以将“ 长宽比”约束应用于UIImageView。

To resize image view ratio-wise you need to give following constraints. 要按比例调整图像视图的大小,您需要指定以下约束。

  • Leading, trailing, top to super view 前导,尾随,顶部到超级视图
  • Aspect ratio to image view 纵横比与图像视图

So as width increases, height will also be increases with ratio. 因此,随着宽度的增加,高度也会随着比率的增加而增加。

Follow below steps:- 请按照以下步骤操作:-

  • Set Equal height UIImage to UIView. 将等高UIImage设置为UIView。

  • Change multiplier which is in Attribute Inspector by click on Equal Height constraint. 通过单击等高约束来更改属性检查器中的乘数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM