通过这个问题,我知道了获取发际线视图的方法,这是一个UIImageView:How to hide iOS7 UINavigationBar 1px bottom line
但是,修改这个视图的背景颜色是非常糟糕的体验,代码如下:
[[self findHairlineImageViewUnder:self.navigationController.navigationBar] setBackgroundColor:[UIColor colorWithHexString:@"ff0000"]];findHairlineImageViewUnder方法来自上面的答案链接
这是有效的,但并不总是,即使放入viewdidload,viewwillapear,viewDidLayoutSubviews,它也会在某些场景中恢复到原始颜色,比如在推送和弹出之后。
所以,我想问一下,有没有完美的方法来改变uinavigationbar的发际线的颜色,谢谢。
发布于 2015-08-17 11:36:35
现在,我发现在发际线的superview中添加一个子视图可以很好地工作
UIView* sv= [[UIView alloc] initWithFrame:[self findHairlineImageViewUnder:self.navigationController.navigationBar].frame];
sv.backgroundColor=[UIColor colorWithHexString:@"ff0000"];
[[self findHairlineImageViewUnder:self.navigationController.navigationBar].superview addSubview:sv];https://stackoverflow.com/questions/32041776
复制相似问题