I have the following view that includes a Navigation Bar, Search Bar and table view - the left picture is the given view I have and the right one is what I want to achieve - basically just hide the navigation bar and resize everything.
Currently I've managed to hide and resize everything using a vertical-space constrain from the search box to the superview top property -
I'm looking for the easiest way to hide the navigation bar and resize the search box + table to fill the whole screen.
Is there any way to do it and take advantage of the iOS 6 auto-layout system?
My current solution feels unnatural.
If that's the only constraint you need to change, then you can create an IBOutlet for that one constraint into your view or view controller, then simply modify the constraint based on when you need it to change:
if(shouldHide){
self.nibTitleBarConstraint.constant = 0.f;
}
else{
self.nibTitleBarConstraint.constant = 44.f;
}
If you'd like to animate the change, then simply stick -layoutIfNeeded
in an animation context:
[UIView animateWithDuration:0.33f
animations:^{
[view layoutIfNeeded];
}];
This is applicable to any constraint's constant you would like to modify (height, top space, etc.) so long as your other constraints know how to react with a change in that view's constraints.
Can you just:
[[self navigationController] setNavigationBarHidden:YES animated:NO];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With