Resize Image without losing quality

后端 未结 4 975
天命终不由人
天命终不由人 2021-01-02 04:50

I\'m using the functions below to resize my images width & height but I noticed that it ruins the image quality.

class func imageWithSize(image: UIImage,         


        
4条回答
  •  粉色の甜心
    2021-01-02 05:22

    func image(image:UIImage,imageSize:CGSize)->UIImage
    {
        UIGraphicsBeginImageContextWithOptions(imageSize, false, 0.0)
        [image .drawInRect(CGRectMake(0, 3, imageSize.width, imageSize.height))]
        let newImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext()
        return newImage;
    }
    

提交回复
热议问题