How to set image to UIImage

后端 未结 12 975
小蘑菇
小蘑菇 2020-12-14 06:20

How can I set image to UIImage object. For example:

UIImage *img = [[UIImage alloc] init];
[img setImage:[UIImage imageNamed:@\"anyImageName\"]]         


        
12条回答
  •  爱一瞬间的悲伤
    2020-12-14 06:53

    may be:

    UIImage *img = [[UIImage alloc] init];
    

    and when you want to change the image:

    img = [UIImage imageNamed:@"nameOfPng.png"];
    

    but the object wasn't in the same place in the memory, but if you use the pointer, the same pointer will be point to the last image loaded.

提交回复
热议问题