iPhone - Mirroring back a picture taken from the front camera

前端 未结 8 2051
半阙折子戏
半阙折子戏 2020-12-24 04:06

When using the front camera of the iPhone 4 to take a picture, the taken picture is mirrored compared with what you see on the iPhone screen. How may I restore the \"on scre

8条回答
  •  情歌与酒
    2020-12-24 04:27

    A slightly simpler answer updated for Swift 3:

    func flipImage(image: UIImage) -> UIImage {
        guard let cgImage = image.cgImage else {
            // Could not form CGImage from UIImage for some reason.
            // Return unflipped image
            return image
        }
        let flippedImage = UIImage(cgImage: cgImage, 
                                   scale: image.scale, 
                                   orientation: .leftMirrored)
        return flippedImage
    }
    

提交回复
热议问题