UIView设置色调颜色
问题描述:
我正在创建一个像标签栏一样的视图。为此,我正在设置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];
但是我无法看到视图。但是,当我取消注释背景颜色代码行时,它显示但没有色调效果。
我该怎么做到这一点。
答
首先,您为什么在刚添加子视图到视图时使用[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];
[UIView的外观] setTintColor:[的UIColor绿彩]; – Rushabh 2014-11-06 10:42:49
如何设置视图? – Nitish 2014-11-06 12:37:28