简体   繁体   English

如何在iPhone应用程序中更改背景颜色

[英]How to change background color in iPhone app

I tried this code in the view controller, but it didn't work. 我在视图控制器中尝试了此代码,但是没有用。 Why is that? 这是为什么?

- (void)viewDidLoad {
 [self setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]];
    [super viewDidLoad];
}

您应该将背景颜色设置为view ,而不是其控制器:

[self.view setBackgroundColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM