ImageView borders are always 240

I have probably a simple mistake that drives me crazy. I am working with UIImageView in a UIScrollView. To match the image in the view, I want to get the image width to adjust the zoom scale. But the code

imageView.bounds.width 

always returns 240.0 no matter what size the actual image is. In the ImageView interface builder, horizontally and vertically in the view, the sub-item of the clip is true, and the mode is in accordance with the format. Any ideas?

+4
source share
2 answers

UIImageView . UIImageView, , 240,0 . , . , :

let image = UIImage("my_image_file")
let imageHeight = image.size.height
let imageWidth = image.size.width

, , .

0

. main_queue, .

 dispatch_async(dispatch_get_main_queue(), {
     print(self.image.bounds.width)
 })
0

All Articles