相对于屏幕宽度的纵横比约束 [英] Aspect ratio constraint relative to the screen width

查看:40
本文介绍了相对于屏幕宽度的纵横比约束的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have set a cell image to my UITableViewCell. It is a custom cell. I have set the aspect ratio as 1:1 and the width of the image view to 50. But for iphone 5 and 5s this size is too big as I feel. So how can I change the size of the UIImageView relative to the screen width. Please help me. Thanks

这是我目前的看法

推荐答案

至少有 2 种方法可以根据屏幕大小配置图像大小:

There are at least 2 ways you could configure image size based on the screen size:

具有纵横比约束的手动方法.通过这种方式,您应该同时选择 ImageView 和单元格的 ContentView,创建等宽"约束并更改它的乘数值.从 1:5 的值开始 - 看起来不错.

Manual approach with Aspect Ration constraint. This way you should select both ImageView and cell's ContentView, create "Equal Width" constraint and change it's multiplier value. Start with a 1:5 value - looking good.

这篇关于相对于屏幕宽度的纵横比约束的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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