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

How to reset navigation bar and status bar in the next page? #2

Open
ghost opened this issue Sep 2, 2015 · 3 comments
Open

How to reset navigation bar and status bar in the next page? #2

ghost opened this issue Sep 2, 2015 · 3 comments

Comments

@ghost
Copy link

ghost commented Sep 2, 2015

I have integrated your code successfully. It is working fine but I am not able to reset the navigation bar and status bar color in the next view controller.Even navigation bar title is moving down in the next view controller.Suppose I clicked one row of the table view then I am opening one view controller using push segue and trying to set navigation color and status bar color as red color. When I will land your page it will reset again. How to do that? I got another problem . I added one refreshControl inside the table view header.then on dragging it is jumping. what is the problem?

@BillCarsonFr
Copy link
Owner

Hi kousik,

If you have issues with the title position it is due to the
[self.navigationController.navigationBar setTitleVerticalPositionAdjustment:delta forBarMetrics:UIBarMetricsDefault];

-> you have to reset it to 0 when landing on your page.

And regarding the navbar appearance, check the 'switchToExpandedHeader' , 'configureNavBar' calls in the controller. They are changing the bar appearance.

@ghost
Copy link
Author

ghost commented Sep 2, 2015

I have tried this inside - viewWillDisappear now navigation bar color is changing but status bar color is getting hidden under the navigation bar and status bar color is become black.

  • (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
    self.navigationController.navigationBar.topItem.title = @"";
    [self.navigationController.navigationBar setTitleVerticalPositionAdjustment:0 forBarMetrics:UIBarMetricsDefault];
    }

@EfrenPerez94
Copy link

EfrenPerez94 commented Jul 9, 2018

Hello, well, I am not pretty sure what do you want to do in the navigation bar and status bar but the ideal form to perform changes is using correctly the lifecycle of ViewControllers, of course, here is a link in order to help you to understand how the lifecycle works.

Here is a example of how you should perform a change in the navigation controller

` class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    configureAppearance()
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    configureAppearance()
}

func configureAppearance() {
    self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
    self.navigationController?.navigationBar.shadowImage = UIImage()
}

}

class SecondViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    configureAppearance()
}

override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    configureAppearance()
}

func configureAppearance() {
    self.navigationController?.navigationBar.setBackgroundImage(nil, for: UIBarMetrics.default)
    self.navigationController?.navigationBar.barTintColor = UIColor.yellow
}

}`

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

No branches or pull requests

2 participants