2016-07-24 84 views
1
@IBAction func mirrorBtn(sender: AnyObject){ 
    self.makeMirroredImage(imageView) 
    pickImage.image = imageView 

} 

func makeMirroredImage(image: UIImage) -> UIImage { 
    var flippedOrientation: UIImageOrientation = .UpMirrored 
    switch image.imageOrientation { 
    case .Down: 
     flippedOrientation = .DownMirrored 
    case .Left: 
     flippedOrientation = .LeftMirrored 
    default : 
     flippedOrientation = .LeftMirrored 
    } 

    let flippedImage: UIImage = UIImage(CGImage: image.CGImage!, scale: image.scale, orientation: flippedOrientation) 
    return flippedImage 
} 
+1

你能提供一些你已经试过的代码吗? – Asdrubal

+0

@Asdrubal我有我的镜像功能。它不工作 – nandinibm

+0

你的意思是这样的吗? http://stackoverflow.com/questions/10936590/flip-nsimage-on-both-axes –

回答

1

选择图像后,您应该能够使用翻译对其进行翻转。我不是iOS/swift专业人员,但在Android中,我通过将XY译文设置为-1来完成此操作。希望这会让你走上正轨