2014-11-06 146 views
1

我正在創建一個像標籤欄一樣的視圖。爲此,我正在設置tintColor:UIView設置色調顏色

UIView *bottomTab = [[UIView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-yVal-bottomBarButtonHeight,SCREEN_WIDTH,75)]; 
//bottomTab.backgroundColor = [UIColor blackColor]; 
bottomTab.tintColor = [UIColor blackColor]; 
[self.view addSubview:bottomTab]; 
[self.view bringSubviewToFront:bottomTab]; 

但是我無法看到視圖。但是,當我取消註釋背景顏色代碼行時,它顯示但沒有色調效果。
我該怎麼做到這一點。

+0

[UIView的外觀] setTintColor:[的UIColor綠彩]; – Rushabh 2014-11-06 10:42:49

+0

如何設置視圖? – Nitish 2014-11-06 12:37:28

回答

0

首先,您爲什麼在剛添加子視圖到視圖時使用[self.view bringSubviewToFront:bottomTab];

將子視圖添加到視圖時,它具有最高的z-Index,因此無論如何它都會位於前端。

其次,你沒有看到視圖的原因,這是因爲它默認情況下具有透明背景。 TintColor不會更改背景顏色,而只會更改放置在視圖中的項目的色調顏色。

您只需在您的視圖中添加一個按鈕,例如測試:

UIView *bottomTab = [[UIView alloc]initWithFrame:CGRectMake(0,SCREEN_HEIGHT-yVal-bottomBarButtonHeight,SCREEN_WIDTH,75)]; 
bottomTab.tintColor = [UIColor blackColor]; 
[self.view addSubview:bottomTab]; 

UIButton *testButton = [UIButton buttonWithType:UIButtonTypeContactAdd]; 
testButton.frame = bottomTab.bounds; 
[bottomTab addSubview:testButton]; 
+0

那麼,我將如何獲得色調效果 – Nitish 2014-11-06 10:36:18

+0

你想實現什麼?你想要一個玻璃視圖嗎? – Lefteris 2014-11-06 10:38:16

+0

我想要實現類似於帶有色調效果的標籤欄或導航欄的視圖。 – Nitish 2014-11-06 12:38:14