我正在尝试使用以下代码在不同尺寸的 iPhone 上检索 ImageView 的宽度和高度
print(self.imageLength.bounds.size.height)
print(self.imageLength.bounds.size.width)
是的,它在 iPhone 5、iPhone 6、iPhone 6 plus 上返回相同的值 128.0。但是界面上显示的 UIImage 确实会根据不同的手机尺寸发生变化。有人知道为什么吗?
这里是图片约束
最佳答案
你可以试试这个
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/