旋转图片

2016-07-01  本文已影响29人  Maggie的小蜗居

不改变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
    }
上一篇下一篇

猜你喜欢

热点阅读