swift - 使用swift通过图像选择器选择后如何镜像图像?

标签 swift uiimagepickercontroller

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

最佳答案

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

关于swift - 使用swift通过图像选择器选择后如何镜像图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38553689/

相关文章:

ios - 尝试从未被点击的 UIImageView 中检测 "touch up"

ios - 在 iOS SDK 上将录制的电影转换为 GIF

ios - 压缩视频时 UIImagePickerController 取消按钮不起作用

ios - UIImagePickerController 不保存图像到 UIImageView

ios - 使用 React Native 组件的 UIImagePickerController 叠加 View

ios - 我正在尝试使用来自 Firebase 实时数据库的数据填充我的 TableView

ios - iOS 上的 PJSIP,编译器错误 "undeclared type ` pj_thread_t`"

swift - 链接 Storyboard 和 swiftUI 的正确子类是什么?

ios - Swift 4 - SceneKit 上的 SpriteKit - 防止触摸底层相机控件

ios - 如何在 Swift 中使用按钮单击功能将 [PHAsset] 转换为 PHAsset