Get underlying NSData from UIImage

前端 未结 6 1308
感情败类
感情败类 2020-12-12 17:41

I can create UIImage from NSData using [UIImage imageWithData:] or [UIImage initWithData:] methods.

I wonder i

6条回答
  •  渐次进展
    2020-12-12 18:13

    Just because I stumbled upon this and i like swift :)

    Here is the swift translation of Caroiline's post.

    var imageData = UIImagePNGRepresentation(image)
    

    Or

    var imageData = UIImageJPEGRepresentation(image, 0.7) 
    

提交回复
热议问题