通过 CGImage 或 CIImage 旋转特定角度
UIImage可通过CGImage或CIImage初始化,初始化方法分别为init(cgImage: CGImage, scale: CGFloat, orientation: UIImageOrientation)和init(ciImage: CIImage, scale: CGFloat, orientation: UIImageOrientation)。通过UIImageOrientation的不同取值,可以使图片旋转90、180、270度。
用原图绘制
通过原图绘制实现旋转图片任意角度。可以先绘制红色背景,效果如下
static