gpt4 book ai didi

iphone - 配置 UIImagePickerController 的帧大小

转载 作者:可可西里 更新时间:2023-11-01 03:37:20 27 4
gpt4 key购买 nike

是否可以更改 UIImagePickerController 的可显示框架大小?我想显示相机 View 但不是在整个屏幕上,而是在 100x100 的边界框中说。

这是我的 viewDidAppear:

- (void) viewDidAppear:(BOOL)animated {

UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = NO;
picker.cameraDevice = UIImagePickerControllerCameraDeviceFront;
picker.cameraViewTransform = CGAffineTransformScale(picker.cameraViewTransform, CAMERA_TRANSFORM_X, CAMERA_TRANSFORM_Y);

[self presentModalViewController:picker animated:YES];

[super viewDidAppear:YES];
}

我在任何地方都找不到这样做的方法...没有人使用它吗?

最佳答案

我试验了上一篇文章中的代码,并注释掉了最终的比例变换((使它成为全尺寸的那个),最后我得到了一个可爱的微型相机 imagePicker 漂浮在我的屏幕中间,所以它绝对有效!我使用的确切代码,包括缩放/淡入过渡,是 -

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];

imagePickerController.delegate = self;
imagePickerController.mediaTypes = [NSArray arrayWithObjects:(NSString *)kUTTypeImage, nil];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

UIView *controllerView = imagePickerController.view;

controllerView.alpha = 0.0;
controllerView.transform = CGAffineTransformMakeScale(0.5, 0.5);

[[[[UIApplication sharedApplication] delegate] window] addSubview:controllerView];

[UIView animateWithDuration:0.3
delay:0.0
options:UIViewAnimationOptionCurveLinear
animations:^{
controllerView.alpha = 1.0;
}
completion:nil
];

[imagePickerController release];

我相信您可以对其进行更多自定义,更改相机 View 的大小和位置。

关于iphone - 配置 UIImagePickerController 的帧大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10164581/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com