iOS - 选择图像区域的最佳方式

时间:2013-03-26 18:41:45

标签: iphone ios image

我正在寻找选择图像区域的最佳方法。 实际上我想加载一些jpg,让用户缩放或移动它,并在图像中心的预绘制正方形图像上获得坐标。 最好的方法是什么?是否有人知道的github库? 提前致谢 再见

1 个答案:

答案 0 :(得分:4)

最好的方法是使用UIImagePickerController类。

你以这种方式调用它:

-(void) choosePhotoFromLibrary{

    UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
    cameraUI.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    // Shows the controls for moving & scaling pictures 
    // To instead hide the controls, use NO.
    cameraUI.allowsEditing = YES;
    cameraUI.delegate = self;

    [self presentViewController:cameraUI animated:YES completion:nil];

}

然后以这种方式获得编辑过的图像:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {


    UIImage * original = info[@"UIImagePickerControllerEditedImage"];
    //Do whatever you want with the image

    [self dismissViewControllerAnimated:YES completion:nil];

}