Apple Interface Builder: adding subview to UIImageView

后端 未结 4 647
情话喂你
情话喂你 2020-11-28 05:55

I created UIImageView with the help of Interface Bulder. Now I want to place label inside it (as its subview). In code I can type something like: [myUIIma

4条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 06:18

    Use this code:

    UIImage *image = [UIImage imageNamed:@"background.png"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    [self.view insertSubview:imageView atIndex:0];
    

    (replace background.png with image) (replace atIndex:0 with whatever place in the .index root you want to insert the image and your off.

提交回复
热议问题