Reputation: 495
So im trying to make a custom camera within my iOS app.
I want to make the camera full screen like snapchats.
But i cant find anywhere that will help me change the aspect ratio from 4:3 (default) to 16:9 (iPhone 5 & 5s, 4" screens).
Can anyone point me in the right direction?
Upvotes: 3
Views: 3572
Reputation: 53112
A little shameless self promotion here, but I have a camera project that does everything you'd like to do, plus you could customize it further for your project. GitHub
It does all the cutting / sizing / aspect ratios for you, while still being fullscreen on all devices.
Otherwise, There's many other options on github / cocoacontrols / elsewhere if you don't like it. You could also make your own by checking out AVFoundation
Upvotes: 4
Reputation: 5902
You need to change the UIImagePickerController's cameraViewTransform:
CGSize screenBounds = [UIScreen mainScreen].bounds.size;
CGFloat cameraAspectRatio = 4.0f/3.0f;
CGFloat camViewHeight = screenBounds.width * cameraAspectRatio;
CGFloat scale = screenBounds.height / camViewHeight;
pickerController.cameraViewTransform = CGAffineTransformMakeTranslation(0, (screenBounds.height - camViewHeight) / 2.0);
pickerController.cameraViewTransform = CGAffineTransformScale(pickerController.cameraViewTransform, scale, scale);
Upvotes: 0