iphone - how can i get the height and width of uiimage

后端 未结 8 1725
温柔的废话
温柔的废话 2020-11-30 18:03

From the URL Image in Mail

I\'m adding image to mail view. It will show full image. But I want to calculate, proportionally change the height and width of the image.

相关标签:
8条回答
  • 2020-11-30 18:50
    let imageView: UIImageView = //this is your existing imageView
    
    let imageViewHeight: CGFloat = imageView.frame.height
    
    let imageViewWidth: CGFloat = imageView.frame.width
    
    0 讨论(0)
  • 2020-11-30 18:52

    Some of the anwsers above, don't work well when rotating device.

    Try:

    CGRect imageContent = self.myUIImage.bounds;
    CGFloat imageWidth = imageContent.size.width;
    CGFloat imageHeight = imageContent.size.height;
    
    0 讨论(0)
提交回复
热议问题