VPImageCropper 可以让你轻松实现微信选取图片并裁剪成头像的控件。
示例代码:
// callback when cropping finished - (void)imageCropper:(VPImageCropperViewController *)cropperViewController didFinished:(UIImage *)editedImage; // callback when cropping cancelled - (void)imageCropperDidCancel:(VPImageCropperViewController *)cropperViewController; // present the cropper view controller VPImageCropperViewController *imgCropperVC = [[VPImageCropperViewController alloc] initWithImage:portraitImg cropFrame:CGRectMake(0, 100.0f, self.view.frame.size.width, self.view.frame.size.width) limitScaleRatio:3.0]; imgCropperVC.delegate = self; [self presentViewController:imgCropperVC animated:YES completion:^{ // TO DO }];