2014-02-10 63 views
0

下面是描述問題的圖片。請注意,UISearchBar上方的區域沒有如下所示的背景。我不想要灰色,我想要拉下UITableView時黑暗褐色的背景。如何使iOS 7中UISearchBar頂部的區域(當在UITableView上時)透明?

我所知道的一切都設置爲[UIColor clearColor],包括視圖的背景等。它在iOS 6中工作正常,但不在iOS 7中正常工作!

我還附加了一個示例項目,以便有人可以看一看,看看我在做什麼錯在這裏?

Click here to download my sample project

也許我只是失去了一些東西愚蠢嗎?

謝謝!

enter image description here

回答

1

兩件事情你可以做:1)增加一個明確清晰的背景欣賞到的UITableView。或者,2)將你的UIImageView設置爲UITableView的背景視圖。

其中任何一項工作。以下是使您的示例工作的代碼:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    UIImageView *backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 
    backgroundImageView.image = [UIImage imageNamed:@"Film_bg.png"]; 
    [self.view addSubview:backgroundImageView]; 
    [self.view sendSubviewToBack:backgroundImageView]; 

    // solution 1 
// self.tableView.backgroundView = [UIView new]; 
// self.tableView.backgroundView.backgroundColor = [UIColor clearColor]; 

    // solution 2 
    self.tableView.backgroundView = backgroundImageView; 
} 
+0

謝謝謝謝謝謝謝謝!解決方案2效果很好! –

相關問題