美文网首页
旋转图片

旋转图片

作者: Maggie的小蜗居 | 来源:发表于2016-07-01 17:45 被阅读29次

    不改变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
        }
    

    相关文章

      网友评论

          本文标题:旋转图片

          本文链接:https://www.haomeiwen.com/subject/ictqjttx.html