我正在寻找选择图像区域的最佳方法。事实上,我想加载一些 jpg,并让用户缩放或移动它并获取图像中心预绘制正方形的图像上的坐标。最好的方法是什么?有没有人知道的 github 库?提前谢谢再见
问问题
477 次
1 回答
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];
}
于 2013-03-26T18:48:47.260 回答