UIImageView

  • 获取自适应图片大小
    private func getImageSize(imageView: UIImageView?) -> CGSize {
        let screenWidth = UIScreen.main.bounds.width
        if let image = imageView?.image {
            let imageSize = image.size
            if imageSize.width <= screenWidth {
                return imageSize
            } else {
                return CGSize(width: screenWidth, height: screenWidth * imageSize.height / imageSize.width)
            }
        }
        return CGSize.zero
    }


你可能感兴趣的:(UIImageView)