Making deep copy of UIImage

前端 未结 6 1768
梦谈多话
梦谈多话 2020-12-16 15:44

My class contains an UIImage property which I want to enforce as a \'copy\' property by any external clients accessing it. But, when I try to do a copy in my custom setter,

6条回答
  •  难免孤独
    2020-12-16 15:54

     CGImageRef newCgIm = CGImageCreateCopy(oldImage.CGImage);
     UIImage *newImage = [UIImage imageWithCGImage:newCgIm scale:oldImage.scale 
                         orientation:oldImage.imageOrientation];
    

提交回复
热议问题