How to get rid of the black ground on the image re

2019-07-08 11:01发布

When using UIImagePicker, it allows to get into Edit mode. Then for an image taken with landscape mode, if user don't scale it manually within the UIImagePicker, there would have black stripe/background on the top and bottom of the image. Is there a way to get rid of that and make that portion of the image to be transparent?

1条回答
姐就是有狂的资本
2楼-- · 2019-07-08 11:48
#pragma mark UIImagePickerControllerDelegate

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

    UIImage *img = nil;

    CGRect cropRect = [[info valueForKey:UIImagePickerControllerCropRect] CGRectValue];

    if (cropRect.origin.y < 0) {

        img = [info objectForKey:UIImagePickerControllerOriginalImage];

    } else {

        img = [info objectForKey:UIImagePickerControllerEditedImage];

    }

}
查看更多
登录 后发表回答