在开发中,个人中心界面,很多需要隐藏navigationBar
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// 将导航栏设为隐藏
[self.navigationController setNavigationBarHidden:YES animated:YES];
}```
然后模拟出一个透明的导航栏
pragma mark ---- 模拟导航栏
-
(void)setNavigationItem
{
// 头部模拟透明的navigationBar
UIView *view = [[UIView alloc] init];
view.frame = CGRectMake(0, 0, WScreenWidth, 64);
// view.backgroundColor = [UIColor yellowColor];
[self.view addSubview:view];self.personalTitleLabel = [[UILabel alloc] init];
self.personalTitleLabel.frame = CGRectMake(40, 34, WScreenWidth - 80, 16);
self.personalTitleLabel.textAlignment = NSTextAlignmentCenter;
self.personalTitleLabel.font = [UIFont boldSystemFontOfSize:17.0f];
self.personalTitleLabel.textColor = [UIColor whiteColor];
self.personalTitleLabel.text = @"我的";
[view addSubview:self.personalTitleLabel];UIButton *personalSettingButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
[personalSettingButton setImage:[UIImage imageWithName:@"navi_set"] forState:
(UIControlStateNormal)];
personalSettingButton.frame = CGRectMake(WScreenWidth - 37, 32, 20, 20);
[personalSettingButton addTarget:self action:@selector(setBtnClick) forControlEvents:(UIControlEventTouchUpInside)];
[view addSubview:personalSettingButton];
}
你说为什么不直接将navigationBar的颜色设置成透明(见上一篇)
当你设置成透明的颜色是,当你推出下个界面的时候,返回时会出现导航栏出现视觉上的bug(一般透明,一般不透明),影响体验
网友评论