ios - Swift - Checking size of UIImageView -
i trying print line debugger/console show dimensions of uiimageview object have. trying use following code error saying uiimageview doesn't have member named 'size'. code:
@iboutlet var image: uiimageview! override func viewdidload() { super.viewdidload() var imageheight = image.size.height var imagewidth = image.size.width print (imageheight) print (imagewidth) }
before question, several points:
don't start name of instance variable upper case.
don't use "image" variable name of image view. suggests uiimage
. it's uiimageview, not uiimage
. call theimageview
.
now question: uiview objects not have size property (uiimage
objects do have size property. might cause of confusion.) have bounds rectangle , frame rectangle. can use theimageview.bounds.size
or theimageview.frame.size
.
Comments
Post a Comment