UIViewController with background image

后端 未结 2 2104
深忆病人
深忆病人 2020-12-18 05:27

How can I insert into my UIViewController an image from the resources as background image? thanks in advance!

相关标签:
2条回答
  • 2020-12-18 06:12

    UIViewControllers don't have background images. Only views themselves have visual attributes.

    UIView does not have a background image property. To display a background image, you usually simply put a UIImageView displaying the image in the view hierarchy so that it appears visually behind all other views. This can be done programmatically or in Interface Builder.

    0 讨论(0)
  • 2020-12-18 06:24

    Add it UIViewController's view, somewhat like this:

    - (void) viewDidLoad 
    {
       UIImage *background = [UIImage imageNamed: @"background.png"];    
       UIImageView *imageView = [[UIImageView alloc] initWithImage: background]; 
    
       [self.view addSubview: imageView]; 
    
       [imageView release];
    
       [super viewDidLoad];
    }
    
    0 讨论(0)
提交回复
热议问题