-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathLEMirroredImagePicker.m
58 lines (41 loc) · 1.44 KB
/
LEMirroredImagePicker.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// LEMirroredImagePicker.m
// LEMirroredImagePicker
//
// Created by Lucas Eduardo on 05/21/2015.
// Copyright (c) 2014 Lucas Eduardo. All rights reserved.
//
#import "LEMirroredImagePicker.h"
@interface LEMirroredImagePicker()
@end
@implementation LEMirroredImagePicker
- (id)initWithImagePicker:(UIImagePickerController*)pickerController
{
self = [super init];
if (self) {
_imagePickerController = pickerController;
}
return self;
}
-(void)mirrorFrontCamera
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(cameraChanged:)
name:@"AVCaptureDeviceDidStartRunningNotification"
object:nil];
}
-(void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"AVCaptureDeviceDidStartRunningNotification" object:nil];
}
#pragma mark - private methods
- (void)cameraChanged:(NSNotification *)notification
{
if(self.imagePickerController.cameraDevice == UIImagePickerControllerCameraDeviceFront)
{
self.imagePickerController.cameraViewTransform = CGAffineTransformIdentity;
self.imagePickerController.cameraViewTransform = CGAffineTransformScale(self.imagePickerController.cameraViewTransform, -1, 1);
} else {
self.imagePickerController.cameraViewTransform = CGAffineTransformIdentity;
}
}
@end