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

后端 未结 8 1742
温柔的废话
温柔的废话 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:43

    There are a lot of helpful solutions out there, but there is no simplified way with extension. Here is the code to solve the issue with an extension:

    extension UIImage {
    
        var getWidth: CGFloat {
            get {
                let width = self.size.width
                return width
            }
        }
    
        var getHeight: CGFloat {
            get {
                let height = self.size.height
                return height
            }
        }
    }
    

提交回复
热议问题