After changing image size, image's transparent part became black

后端 未结 2 1870
清酒与你
清酒与你 2021-01-27 05:34

I am trying to change image size according to my view so I wrote this code for that.

 -(UIImage *)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize
{
          


        
2条回答
  •  北海茫月
    2021-01-27 05:46

    You should use NO as the second argument, that toggles the transparency of the image.

    UIGraphicsBeginImageContextWithOptions(newSize, NO, [UIScreen mainScreen].scale);
    

    Check out Apple's documentation for more details.

提交回复
热议问题