Should I use UIImage or CGImage in a Swift iOS App?

前端 未结 3 1018
感动是毒
感动是毒 2020-12-14 23:27

All the code I can find revolves around loading images directly into visual controls.

However, I have my own cache system (converting a project from another language

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-15 00:25

    You can load your image easily into an UIImage object...

    NSData *data = [NSData dataWith...];
    UIImage *image = [UIImage imageWithData:data];
    

    If you then want to show it in a view, you can use an UIImageView:

    UIImageView *imageView = [[UIImageView alloc] init]; // or whatever
    ...
    imageView.image = image;
    

    See more in UIImage documentation.

提交回复
热议问题