簡體   English   中英

使用相機iOS捕獲和自定義裁剪圖像

[英]Capture and custom crop image with camera iOS

我正在使用UIImagePickerController捕獲圖像。 現在我要裁剪圖像。 我正在使用UIImagePicker cameraOverlayView方法,但不允許移動裁剪視圖。 我希望我的裁剪視圖應可移動且可調整大小,以便用戶可以選擇要使用的圖像部分。 我正在使用以下代碼:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM