【Swift】iOS裁剪或者压缩后出现的白边问题

只需要将所有的CGFloat转化为NSInteger即可

    func imageScaleSize(newSize: CGSize) -> UIImage{

        let width = NSInteger(newSize.width)

        let height = NSInteger(newSize.height)

        UIGraphicsBeginImageContext(CGSize( width, height: height));

        self.drawInRect(CGRect(x: 0, y: 0, width, height: height))

        let newImage = UIGraphicsGetImageFromCurrentImageContext()

        UIGraphicsEndImageContext();

        return newImage;

    }

原文地址:https://www.cnblogs.com/melons/p/5791959.html