The user picks an image with picker and the following code manipulates the image

    UIImage *image = info[UIImagePickerControllerOriginalImage]; 
    _imageView.image = image;
    _imageView.contentMode = UIViewContentModeScaleAspectFill;
    _imageView.layer.cornerRadius = 10;
    _imageView.clipsToBounds = YES;
    _imageView.layer.shouldRasterize = YES;
    _imageView.layer.rasterizationScale = [[UIScreen mainScreen] scale];

When I send imageView to the server it is sending the original image and not the new image. I am guessing this is because UIImageView does not actually change the image but is just making on the fly visual changes to the original image.

Can someone lead me in the right direction as to either what I need to learn in order to make permanent changes to an image/create new image or is there a simple way to make these changes I've made permanent?

Thanks

有帮助吗?

解决方案

I suppose you talking about getting a new image like it appear on screen (with the corner radius set etc etc) so you might want to test some like that :

UIGraphicsBeginImageContext(self.imageView.image.size);

[self.imageView drawViewHierarchyInRect:self.imageView.frame afterScreenUpdates:YES];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top