Making deep copy of UIImage

前端 未结 6 1714
梦谈多话
梦谈多话 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 16:16

    Because the image itself is a pointer, you need to create an image context, draw the image into the context, and then get the original image from the context. Maybe you need to use the UIImage.CGImage.

提交回复
热议问题