使用相机捕获和自定义裁剪图像 iOS
Capture and custom crop image with camera iOS
我正在使用 UIImagePickerController
来捕捉图像。现在我想裁剪图像。我正在使用 UIImagePicker
的 cameraOverlayView
方法,但它不允许移动我的裁剪视图。我希望我的裁剪视图应该是可移动和可调整大小的,以便用户可以 select 使用图像部分。
我正在使用以下代码:
UIImagePickerController *cameraPicker = [[UIImagePickerController alloc] init];
cameraPicker.delegate = self;
cameraPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraPicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
cameraPicker.cameraOverlayView =overlay;
cameraPicker.allowsEditing = NO;
[self presentViewController:cameraPicker animated:YES completion:nil];
谁能建议我该怎么做?
- (void)pickphoto:(UIImagePickerControllerSourceType)sourceType
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.navigationBar.tintColor=[UIColor blackColor];
imagePicker.navigationItem.title=@"Photo Albums";
imagePicker.AllowsEditing = TRUE;
imagePicker.delegate = self;
imagePicker.sourceType = sourceType;
[self presentModalViewController:imagePicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
_imageV.image = image;
_imageV.layer.borderColor=[UIColor whiteColor].CGColor;
_imageV.layer.borderWidth=1.0;
[imagePicker dismissModalViewControllerAnimated:YES];
}
我正在使用 UIImagePickerController
来捕捉图像。现在我想裁剪图像。我正在使用 UIImagePicker
的 cameraOverlayView
方法,但它不允许移动我的裁剪视图。我希望我的裁剪视图应该是可移动和可调整大小的,以便用户可以 select 使用图像部分。
我正在使用以下代码:
UIImagePickerController *cameraPicker = [[UIImagePickerController alloc] init];
cameraPicker.delegate = self;
cameraPicker.sourceType = UIImagePickerControllerSourceTypeCamera;
cameraPicker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
UIView *overlay = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
cameraPicker.cameraOverlayView =overlay;
cameraPicker.allowsEditing = NO;
[self presentViewController:cameraPicker animated:YES completion:nil];
谁能建议我该怎么做?
- (void)pickphoto:(UIImagePickerControllerSourceType)sourceType
{
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.navigationBar.tintColor=[UIColor blackColor];
imagePicker.navigationItem.title=@"Photo Albums";
imagePicker.AllowsEditing = TRUE;
imagePicker.delegate = self;
imagePicker.sourceType = sourceType;
[self presentModalViewController:imagePicker animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
_imageV.image = image;
_imageV.layer.borderColor=[UIColor whiteColor].CGColor;
_imageV.layer.borderWidth=1.0;
[imagePicker dismissModalViewControllerAnimated:YES];
}