Reputation: 5616
I have the below code in my app which displays a UIImagePicker minus the camera controls.
#define CAMERA_SCALAR 1.32
@implementation CameraViewController
- (id)init {
// Remove standard controls from UIImagePicker and make full screen
if (self = [super init]) {
self.sourceType = UIImagePickerControllerSourceTypeCamera;
self.showsCameraControls = NO;
self.navigationBarHidden = YES;
self.toolbarHidden = YES;
self.wantsFullScreenLayout = YES;
self.cameraViewTransform = CGAffineTransformScale(self.cameraViewTransform, 1, CAMERA_SCALAR);
}
return self;
}
Initially when I removed set showsCameraControls to NO I got a black bar on the screen where the controls had been. To offset this I added in the self.cameraViewTransform line to scale up the view.
This works, however it distorts the image. I think what I need to do is also scale the height by the same ratio as the width.
Can anyone advise me on the best way to do this ?
Thanks in advance !
Upvotes: 3
Views: 2072
Reputation: 4463
I may be misinterpreting your question, but to scale the width as well, you can
self.cameraViewTransform = CGAffineTransformScale(self.cameraViewTransform, CAMERA_SCALAR, CAMERA_SCALAR);
instead of
self.cameraViewTransform = CGAffineTransformScale(self.cameraViewTransform, 1, CAMERA_SCALAR);
But of course, this will push the sides of the camera view out of screen.
In principle, I think there is no best choice in this case (showing exactly what the camera shows in fullscreen), because the origin of the problem is the difference of the aspect ratio of the screen/camera. You either have to miss part of the view, or distort the view, is my thinking.
Upvotes: 1