Type' UIImage'的价值没有会员

时间:2015-12-07 04:34:37

标签: swift uiimage swift2

我得到的错误说:

  

Type' UIImage的价值'没有会员' thumbnailImage'

我搜索了其他问题和解决方案,但我不了解如何将它们应用到我的代码中。请帮我解决这个问题。

let image = UIImage(data: newProfilePictureData)
let mediumImage: UIImage = image!.thumbnailImage(280, transparentBorder: 0, cornerRadius: 0, interpolationQuality: CGInterpolationQuality.High)
let smallRoundedImage: UIImage = image!.thumbnailImage(64, transparentBorder: 0, cornerRadius: 0, interpolationQuality: CGInterpolationQuality.Low)

1 个答案:

答案 0 :(得分:0)

这是您可以从原始图像生成拇指图像的方法:

func generateThumbImage() -> UIImage{

        let image: UIImage = UIImage(data: newProfilePictureData)
        let thumbSize = CGSizeMake(100, 100)
        UIGraphicsBeginImageContext(thumbSize)
        image.drawInRect(CGRectMake(0, 0, thumbSize.width, thumbSize.height))
        let thumbImage = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return thumbImage
    }