我正在努力使uiview看起来像ios 8中的默认uinavigationbar。
我不想对值进行硬编码,因此想要在底部采用uinavigationbar颜色,高度,宽度和边框,并将其应用于自定义uiview。
有什么办法可以实现吗?
self.headerBar.backgroundColor = self.navigationController.navigationBar.backgroundColor;
我尝试了以上但是没有用。
答案 0 :(得分:0)
K我最后必须结合以下
[UIColor colorWithRed:(247 / 255.0)绿色:(247 / 255.0)蓝色:(247 / 255.0)alpha:1];
用于uiview颜色,而不是放在另一个uiview中,我将其作为子视图添加到原始视图中,其高度较小,使其看起来像边框,并使其颜色为深灰色和alpha 0.4f。这里需要注意的一点是,边框也可以使用图层创建,但默认情况下dons会处理方向更改。
至于高度宽度,只根据要附加此自定义导航栏的超视图边界给出高度宽度。
答案 1 :(得分:0)
您可以使用UIToolBar
并相应地设置其属性,如UINavigationBar
,tintColor
,barTintColor
,translucent
等。
注意:UIToolBar
继承自UIView
如果您使用UIView
并希望获取导航栏颜色,则应使用barTintColor
属性,而不是backgroundColor
self.headerBar.backgroundColor = self.navigationController.navigationBar.barTintColor;