wes. i
wes. i

Reputation: 628

Get UIImageView's width and height programmatically issue

i'm trying to retrieve the width and height of an image view on different size of iPhone with the following code

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

yup, it return the same value 128.0 on iPhone 5, iPhone 6, iPhone 6 plus. but the UIImage shows on interface does changed according to different phone size. Does anyone why?

Here is the image constraints

enter image description here

Upvotes: 1

Views: 826

Answers (1)

Lee
Lee

Reputation: 848

you can try this

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

print(imgWidth)
print(imgHeight)

Upvotes: 3

Related Questions