删除navigationBar下面的横线方法
- 声明用来存放下方横线的属性
_navBarHairlineImageView = [self findHairlineImageViewUnder:self.navigationController.navigationBar];
- 设置找到该横线的方法
- (UIImageView *)findHairlineImageViewUnder:(UIView *)view {
/** 如果这个类是UIImageView类并且高度小于1 的话直接返回. */
if ([view isKindOfClass:UIImageView.class] && view.bounds.size.height <= 1.0) {
return (UIImageView *)view;
}
/** 遍历传入的view上面的子视图. */
for (UIView *subView in view.subviews) {
/** 回调此方法. 直到找到下方横线的ImageView并返回*/
UIImageView *imageView = [self findHairlineImageViewUnder:subView];
if (imageView) {
return imageView;
}
}
return nil;
}
- 在
- (void)viewWillAppear:(BOOL)animated
和- (void)viewWillDisappear:(BOOL)animated
两个方法中设置view 的隐藏.
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
_navBarHairlineImageView.hidden = YES;
}
- (void)viewWillDisappear:(BOOL)animated {
[super viewWillDisappear:animated];
_navBarHairlineImageView.hidden = NO;
}
这样就可以是下方的横线消失.
设置title字体颜色和大小
self.navigationItem.title = @"通讯录";
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName : [UIFont boldSystemFontOfSize:18]};
设置leftBarButtonItem的颜色
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
网友评论