gpt4 book ai didi

xcode - 以编程方式获取 UIImageView 的宽度和高度问题

转载 作者:搜寻专家 更新时间:2023-11-01 06:40:37 26 4
gpt4 key购买 nike

我正在尝试使用以下代码在不同尺寸的 iPhone 上检索 ImageView 的宽度和高度

print(self.imageLength.bounds.size.height)
print(self.imageLength.bounds.size.width)

是的,它在 iPhone 5、iPhone 6、iPhone 6 plus 上返回相同的值 128.0。但是界面上显示的 UIImage 确实会根据不同的手机尺寸发生变化。有人知道为什么吗?

这里是图片约束

enter image description here

最佳答案

你可以试试这个

let imgWidth = myImageView.layer.frame.width
let imgHeight = myImageView.layer.frame.height

print(imgWidth)
print(imgHeight)

关于xcode - 以编程方式获取 UIImageView 的宽度和高度问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35884930/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com