ios - 使用相机 iOS 捕获和自定义裁剪图像

标签 ios image camera crop resize-crop

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

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

关于ios - 使用相机 iOS 捕获和自定义裁剪图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31964498/

相关文章:

ios - CocoaPods 因错误停止安装 Firebase/Analytics

iphone - 如何在 iOS5 中的一个请求中获取多个 user_timeline?

python - Raspberry pi 不会显示 pil 图像

image - 钛:相机使应用程序崩溃

ios - Xcode 预处理器宏检查 Base SDK 是否 >= iOS 7.0

iphone - 使用 UITapGestureRecognizer 根据 iPhone 中的手指触摸位置添加新 View

android - 如何在 Canvas 中使用部分图像

image - 有效的jpeg文件最小大小(以字节为单位)

android - Android 应用中的相机方向

android - 在您的程序中使用人脸检测