Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ios10返回navigationBar颜色不会立马消失 #51

Open
ZCLemo opened this issue Oct 11, 2016 · 7 comments
Open

ios10返回navigationBar颜色不会立马消失 #51

ZCLemo opened this issue Oct 11, 2016 · 7 comments

Comments

@ZCLemo
Copy link

ZCLemo commented Oct 11, 2016

1

@xd54622
Copy link

xd54622 commented Feb 15, 2017

+1

@xd54622
Copy link

xd54622 commented Feb 15, 2017

我试了一下,在上一个页面的ViewWillAppear里面,再用lt_setBackgroundColor,可以解决这种变化突兀的情况。感觉这就需要在相关的页面都设置这个,还是略麻烦。

@github410117
Copy link

我在ViewWillAppear设置了,还是有这种情况呢?

@sseen
Copy link

sseen commented Jun 15, 2017

我也有这样的情况,上一层 viewWillAppear 并不能解决问题, @xd54622 请教下你是怎么设置的?

@xd54622
Copy link

xd54622 commented Jun 16, 2017

@sseen @github410117 我就是在上一层的viewWillAppear上加一个设置背景颜色的,感觉效果还好啊。
这是第一个页面设置的:

  • (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    // 这里是为了避免导航栏出现突兀的情况
    [self.navigationController.navigationBar lt_setBackgroundColor:navBgColor];
    }

  • (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar lt_reset];
    }

然后在第二个页面是这样设置的:

  • (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.tableView.delegate = self;
    [self scrollViewDidScroll:self.tableView];
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    }

  • (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.tableView.delegate = nil;
    [self.navigationController.navigationBar lt_reset];
    }

@sseen
Copy link

sseen commented Jun 16, 2017

@xd54622 谢了你的回复。不过还是没有任何作用,我只能不使用[self.navigationController.navigationBar lt_reset] 而用 [self.navigationController.navigationBar lt_setBackgroundColor:navBgColor] 来给子页面的导航栏设置颜色,依然不能用 uinavigationbar 的 appearance 来全局设置颜色,即便这样,效果也只是勉强能接受

@acumen1005
Copy link

同样遇到这个问题,通过这样一下方式解决(不是最佳实践,效果还能接受):

将 push 进来的页面的 backIndicator 用 leftBarButtonItem 代替。然后在点击方法中 pop 页面,就就会出现上面的现象

缺陷:

  1. 用 leftBarButtonItem 代替之后系统自带的滑动返回失效(可以解决)
  2. 视图(返回按钮位置)上可能有些偏差

希望能帮到你们~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants