2010-06-07 60 views

回答

18

它添加UIViewController的观点,有点像这样的:你,我已经看了很多帖子关于背景图像和试过各种代码,没有工作

- (void) viewDidLoad 
{ 
    UIImage *background = [UIImage imageNamed: @"background.png"];  
    UIImageView *imageView = [[UIImageView alloc] initWithImage: background]; 

    [self.view addSubview: imageView]; 

    [imageView release]; 

    [super viewDidLoad]; 
} 
+0

我在顶部看到约10px的边距。有什么我失踪了吗? – 2011-04-29 03:19:16

+0

@vishalashah在将其添加为子视图之前,尝试将imageview的框架设置为viewcontroller视图的框架。 – luvieere 2011-04-29 05:31:05

+4

对于背景视图,您可能想要使用'[self.view insertSubview:imageView atIndex:0];否则它会在其他xib的东西之上。 – Intentss 2012-11-22 19:16:43

8

UIViewControllers没有背景图像。只有视图本身具有视觉属性。

UIView没有背景图像属性。要显示背景图像,通常只需将UIImageView显示在视图层次结构中,以便在所有其他视图之后以可视方式显示。这可以通过编程或在Interface Builder中完成。

+0

谢谢,这似乎与故事板这是完成的最佳方式。谢谢。 – Ergin 2014-09-17 20:54:39