不改变View的情况下,旋转view里面的图片
func rotateImage(image:UIImage) -> UIImage {
let orientation:UIImageOrientation = image.imageOrientation
var sourceImage = UIImage()
switch orientation {
case .Up:
sourceImage = UIImage(CGImage: image.CGImage!,scale:1,orientation:.Left)
break
case .Left:
sourceImage = UIImage(CGImage: image.CGImage!,scale:1,orientation:.Down)
break
case .Down:
sourceImage = UIImage(CGImage: image.CGImage!,scale:1,orientation:.Right)
break
case .Right:
sourceImage = UIImage(CGImage: image.CGImage!,scale:1,orientation:.Up)
break
default:
break
}
return sourceImage
}
网友评论