使用UIImagePicker时,如何摆脱UIImagePickerControllerEditedImage返回的图像上的黑色底线

时间:2012-05-08 00:24:37

标签: iphone ios uiimage uiimagepickercontroller

使用UIImagePicker时,它允许进入编辑模式。然后对于使用横向模式拍摄的图像,如果用户不在UIImagePicker中手动缩放,则图像的顶部和底部会出现黑色条纹/背景。有没有办法摆脱它,使图像的那部分透明?

1 个答案:

答案 0 :(得分:3)

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

    }

}