user6567889 user6567889 - 4 months ago 33
Swift Question

How I can mirror an image after selecting through image picker using swift?

@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
}

Answer

After the image is selected you should be able to invert it using a translation. I'm not a professional with iOS/swift, but in Android I accomplished this by setting the X and Y translation to -1. Hope this puts you on the right track

Comments