使用相机iOS捕捉和自定义裁剪图像

时间:2015-08-12 11:55:05

标签: ios image camera crop resize-crop

我正在使用UIImagePickerController来捕捉图像。现在我想裁剪图像。我正在使用cameraOverlayView UIImagePicker方法,但它不允许移动我的裁剪视图。我希望我的裁剪视图应该是可移动和可调整大小的,以便用户可以选择要使用的图像部分。 我使用以下代码:

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];

任何人都可以建议我该怎么做?

1 个答案:

答案 0 :(得分:3)

- (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];
}