[英]ipad : how to change background color for Ipad app?
我正在为iPhone和iPad开发应用程序,它在iPhone上运行良好,但对于iPad,它提供了这种全灰色背景色,而我想要全蓝色背景色。 我正在使用两个xib文件并在代码中执行此操作。 我用iphone工作得很好,但没有用ipad工作。
- (void)viewDidLoad {
[super viewDidLoad];
[[NSBundle mainBundle] loadNibNamed:@"LoginHeaderViewController" owner:self options:nil];
self.tableView.tableHeaderView = tableHeaderView;
[[NSBundle mainBundle] loadNibNamed:@"LoginFooterViewController" owner:self options:nil];
self.tableView.tableFooterView = tableFooterView;
self.view.backgroundColor = [UIColor colorWithRed: (66.0/255) green: (142.0/255) blue: (189.0/255) alpha: 1.0];
}
我甚至把这些线放在上面的代码然后它给出下面的pic结果,否则它显示所有灰色背景。
tableHeaderView.backgroundColor = [UIColor colorWithRed: (66.0/255) green: (142.0/255) blue: (189.0/255) alpha: 1.0];
tableFooterView.backgroundColor = [UIColor colorWithRed: (66.0/255) green: (142.0/255) blue: (189.0/255) alpha: 1.0];
尝试这个 :
[myTableView setBackgroundView:nil];
tableview.backgroundColor = color;
使用以下方法将背景视图设置为nil:
tableview.backgroundView = nil;
希望它会奏效
如果您想要蓝色背景颜色,则无需为tableHeader和tableFooter指定颜色,因为self.view的颜色为蓝色。 因此,请进行以下更改:
tableHearder.backgroundColor = [UIColor clearColor];
tableHeader.backgroundView = nil;
tableFooter.backgroundColor = [UIColor clearColor];
tableFooter.backgroundView = nil;
[myTableView setBackgroundView:nil];
[myTableView setBackgroundView:[[[UIView alloc] init] autorelease];
这将适合您的背景颜色变化
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.