2016-07-24 140 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來完成此操作。希望這會讓你走上正軌