简体   繁体   English

ipad:如何更改Ipad应用程序的背景颜色?

[英]ipad : how to change background color for Ipad app?

I am developing application for iPhone and iPad both, its working fine in iPhone but for iPad it gives this full gray background color, while I want full blue background color. 我正在为iPhone和iPad开发应用程序,它在iPhone上运行良好,但对于iPad,它提供了这种全灰色背景色,而我想要全蓝色背景色。 I am using two xib files and doing this in code. 我正在使用两个xib文件并在代码中执行此操作。 I works fine with iphone but not with ipad. 我用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]; 

}

I even put these lines In above code then It gives the below pic result otherwise it show all gray background. 我甚至把这些线放在上面的代码然后它给出下面的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;

Set background view to nil using following : 使用以下方法将背景视图设置为nil:

 tableview.backgroundView = nil;  

Hope it will work 希望它会奏效

If you want blue background color then there is no need to assign color to tableHeader and tableFooter as the color of self.view is blue. 如果您想要蓝色背景颜色,则无需为tableHeadertableFooter指定颜色,因为self.view的颜色为蓝色。 So make the following changes: 因此,请进行以下更改:

tableHearder.backgroundColor = [UIColor clearColor];
tableHeader.backgroundView = nil;

tableFooter.backgroundColor = [UIColor clearColor];
tableFooter.backgroundView = nil;
[myTableView setBackgroundView:nil];
[myTableView setBackgroundView:[[[UIView alloc] init] autorelease];

This will suit your background color change 这将适合您的背景颜色变化

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

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