How to set image to UIImage

后端 未结 12 941
小蘑菇
小蘑菇 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:55

    Create a UIImageView and add UIImage to it:

    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image Name"]] ;
    

    Then add it to your view:

    [self.view addSubView: imageView];
    

提交回复
热议问题