【发布时间】:2013-12-06 15:27:12
【问题描述】:
我在 iOS 7 应用中有一个UIDatePicker。它被添加到视图控制器(子类)中,因为背景是黑色的,所以它几乎不可读。 (日期选择器需要浅色背景。)
- (void)loadView
{
self.datePicker = [[UIDatePicker alloc] init];
...
[self.view addSubview:self.datePicker];
// When placed here, without viewDidAppear, background remains black/transparent
self.view.backgroundColor = [UIColor whiteColor];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
// When places here, the background becomes indeed white.
self.view.backgroundColor = [UIColor whiteColor];
}
我当然可以在loadView 中设置日期选择器本身的背景颜色,这就是我最终要做的。
但我仍然不明白为什么在loadView 中设置超级视图的背景颜色不起作用。
【问题讨论】:
标签: ios iphone uiview uiviewcontroller ios7