[英]Fixed width and height of the UIImage using Swift (AutoLayout)
I am trying to put my image at the center & want to keep the width & height of the image fixed. 我试图将图像居中放置,并希望保持图像的宽度和高度固定。
I have tried adding constraints : equal width, equal height and have also added a constraint to keep some padding below the label. 我尝试添加约束:宽度相等,高度相等,并且还添加了约束以在标签下方保留一些填充。
When I run it, the size of the image is scaled up and it goes to the top right. 当我运行它时,图像的大小将按比例放大,并移到右上角。
I have tried a lot of permutations & combinations to get it where it in the middle, not of them as worked so far. 我尝试了很多排列组合以使其居中,而不是到目前为止的排列。
According to your requirement, set the constraints 根据您的要求,设置约束
Not equal width
, equal height
. equal width
不equal width
, equal height
不equal width
。 And I believe going to the top right is because there's no valid horizontal alignment. 我认为转到右上角是因为没有有效的水平对齐方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.