簡體   English   中英

ipad:如何更改Ipad應用程序的背景顏色?

[英]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;  

希望它會奏效

如果您想要藍色背景顏色,則無需為tableHeadertableFooter指定顏色,因為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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM