相对于屏幕宽度的纵横比约束

Aspect ratio constraint relative to the screen width

我已经为我的 UITableViewCell 设置了一个细胞图像。它是一个自定义单元格。我已将宽高比设置为 1:1,图像视图的宽度设置为 50。但是对于 iphone 5 和 5s,我觉得这个尺寸太大了。那么如何更改 UIImageView 相对于屏幕宽度的大小。 请帮我。 谢谢

这是我当前的观点

至少有两种方法可以根据屏幕尺寸配置图像尺寸:

  • Size-Classes allows you to set different width constraint value based on Trait Variation: Compact or Regular. Just select the width constraint, click on the Plus button on the left of it's Constant value and add a new variation for the iPhone device screens.

  • 具有纵横比约束的手动方法。这样你应该 select ImageView 和单元格的 ContentView,创建 "Equal Width" 约束并改变它的乘数值。从 1:5 值开始 - 看起来不错。