保存する前にUIImageを左右反転してあげればいいと思います。
左右反転する方法は
http://temping-amagramer.blogspot.jp/2013/10/iosobjective-cuiimage.html?m=1
これとか参考にすればどうでしょう。
追記
試してみると想像以上に難しいものでした。
それにすみません。提示した参考サイトを元に自分でやってみるとうまく反転しませんでした。
多分OSバージョンが違うからかキャプチャの方法が違うからだと思いますが……
良さげなURLが見つからなかったので自分で実装してみました。
一応手元で試した限りではうまく動くみたいです。
Swift
1func flipHorizontal(image: UIImage) -> UIImage {
2 let originalOrientation = image.imageOrientation
3
4 // UIImageに設定されている回転方向を初期化したUIImageを作成.
5 // 'UIImageOrientation.Up'はホームボタンが右手にある状態. これがデフォルトらしい.
6 let landscapeImage = UIImage(CGImage: image.CGImage!, scale: image.scale, orientation: .Up)
7
8 UIGraphicsBeginImageContextWithOptions(landscapeImage.size, false, landscapeImage.scale)
9 let context = UIGraphicsGetCurrentContext()
10
11 // CGContextDrawImageで描画する場合、左下が原点となる.
12 // 扱いやすい右上を原点とするために上下反転する.
13 CGContextTranslateCTM(context, 0, landscapeImage.size.height)
14 CGContextScaleCTM(context, 1.0, -1.0)
15
16 // 左右を反転する.
17 // 元画像が横向きだったらそのまま左右反転でいいが、縦向きだったら90度回転しているので上下反転する.
18 switch originalOrientation {
19 case .Up, .UpMirrored, .Down, .DownMirrored:
20 // 左右反転
21 CGContextTranslateCTM(context, landscapeImage.size.width, 0)
22 CGContextScaleCTM(context, -1.0, 1.0)
23 case .Left, .LeftMirrored, .Right, .RightMirrored:
24 // 上下反転
25 CGContextTranslateCTM(context, 0, landscapeImage.size.height)
26 CGContextScaleCTM(context, 1.0, -1.0)
27 }
28 // 画像を描画
29 CGContextDrawImage(context, CGRect(origin: CGPoint.zero, size: landscapeImage.size), landscapeImage.CGImage)
30 // 画像取得
31 let flipHorizontalImage = UIGraphicsGetImageFromCurrentImageContext()
32
33 UIGraphicsEndImageContext()
34
35 // 最初に無効にしたUIImageの回転を再設定する
36 return UIImage(CGImage: flipHorizontalImage.CGImage!, scale: flipHorizontalImage.scale, orientation: originalOrientation)
37}
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/01/28 16:40
2016/01/29 00:12
2016/01/29 03:51
2016/01/31 08:42
2016/01/31 15:36
2016/01/31 23:01 編集