twitterprofilepage
twitterprofilepage copied to clipboard
How to reset navigation bar and status bar in the next page?
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?
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.
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]; }
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
}
}`