重新定位相机视图

时间:2014-02-26 19:30:38

标签: objective-c uiimagepickercontroller camera-overlay

我为我的UIImagePickerController创建了OverlayView。 有没有办法重新定位观众出现的位置?目前,观众被一直推到设备的一侧,黑色的盒子填满了屏幕的剩余部分。

- (IBAction)presentCameraView:(id)sender {

_picker = [[UIImagePickerController alloc] init];
_picker.sourceType = UIImagePickerControllerSourceTypeCamera;

// Set flag to allow the alert to be shown
_showAlert = YES;
_endAlerts = NO;

_overlay = [[[NSBundle mainBundle] loadNibNamed:@"CameraOverlay" owner:self options:nil] objectAtIndex:0];
_picker.delegate = self;
_picker.wantsFullScreenLayout = YES;
_picker.allowsEditing = NO;
_picker.cameraOverlayView = _overlay;
_picker.showsCameraControls = NO;
[self presentViewController:_picker animated:YES completion:NULL];
}

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:1)

所以,经过大量的观察,我终于遇到了一些让我重新定位相机视图以及改变它的大小的东西。

CGAffineTransform translate = CGAffineTransformMakeTranslation(0.0, 71.0); 
//This slots the preview exactly in the middle of the screen by moving it down 71 points

CGAffineTransform scale = CGAffineTransformScale(translate, 0.8888889, 1);
//This scales the view to the size that you want it.

_picker.cameraViewTransform = scale;