user6567889 user6567889 - 1 year ago 122
Swift Question

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

@IBAction func mirrorBtn(sender: AnyObject)


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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download