下面兩段代碼都放在UINavigationController 或者自定義的UINavigationController
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
// 運(yùn)用遞歸影藏自帶的黑線
[self hideBorderInView:self.navigationBar];
// 需要設(shè)置成的樣子
if (!_navLineV) {
_navLineV = [[UIView alloc]initWithFrame:CGRectMake(0, 44, kScreen_Width, 1.0/ [UIScreen mainScreen].scale)];
_navLineV.backgroundColor = kColorCCC;
_navLineV.backgroundColor = [UIColor redColor];
[self.navigationBar addSubview:_navLineV];
}
}
// 遞歸 遍歷view的subViews 直至隱藏
- (void)hideBorderInView:(UIView *)view{
if ([view isKindOfClass:[UIImageView class]]
&& view.frame.size.height <= 1) {
view.hidden = YES;
}
for (UIView *subView in view.subviews) {
[self hideBorderInView:subView];
}
}
- 設(shè)置后的效果
image
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者