How to prevent visual glitchs on push animation when UINavigationBar height changes? - ios

I have a visual glitch specific to iOS 11.
I have a navigation controller with a search bar and on item click I push another view Controller. Before iOS 11, the animation is clean because the navigation bar height does not change between the source view controller and the destination view controller.
With iOS 11, the Search Bar is taller, so navigation bar height changes during push animations and I have visual glitch.
I tried to force navigation bar height without success. Any idea how to handle this?

Related

Navigation bar item automatically changes its height and position in storyboard

I have a project which was build in Xcode 8.2 and now when I run it using Xcode 9.2. I am facing problems with the custom navigation title and bar buttons in the view controllers. In my storyboard I have a View Controller and on its Navigation bar I have a custom navigation view with a label used as the navigation title.
Since we cannot add constraints on the navigation view, I have given autolayout for both the view and label. Now when I run the project, the custom navigation title has disappeared. So I opened the storyboard to check what really happened, I was shocked to see that navigation view's origin.y value is changed to some other value, like -44, -88, etc. Now I edited the origin.y value, saved and run the project, but still the view was not seen. So now when I checked back in the storyboard the frame of the view was changed to some other value. I tried creating new custom navigation view, but no luck. This keeps happening and I am really worried. I really appreciate if you guys can give me some information on this issue.
Click to show screenshot of custom view in the navigation bar

iPhone X - Hidden status bar pushes Navigation Bar upwards

I'm testing iPhone X behavior using the Xcode simulator. For some odd reason, if I'm hiding the Status Bar the Navigation Bar pushed upwards causing the title to completely disappear and cutting the left and right buttons. This is happening only on the iPhone X.
Illustration:
How can I hide the status bar and keep the Navigation Bar at a visible position?
UPDATE:
Sample project for your convince:
https://drive.google.com/file/d/0B5qJARV-Oc9ra1hvZkpXZm9lRUE/view?usp=sharing
One solution is to embed the navigation controller inside a container view controller which is properly constrained to the safe area.
Just create another view controller and drag a "Container View" from the Object Library. This view has top, bottom, leading, and trailing constraints to the safe area, all with constants equal to 0. If you control-drag from the container view to the navigation controller, you'll get an option to set an "embed segue" which will embed the selected view controller as a child view controller.
I set the status bar to be hidden on the new view controller I created, and it works fine.
This feels like something that UINavigationBar should handle automatically, but this workaround seems like it should work pretty well.
Another note: if you change the color of the navigation bar, you'll also need to create another view above the container view, and change its color to match the color of the navigation bar.
I, for a small app, changed from using a Push to a Modal segue and adding in my own navigation bar. I used Push because it looks good, and already had a Modal for another part, which I wanted to animate differently for style reasons.
For smaller apps this may be the quickest and easiest solution, but my next update I need to use the navigation controller. For that I think I'll switch on the status bar, which is no big deal for me and allows it to work.
I think you need to use "safeAreaLayoutGuide" new update in iOS 11
Apple has provided us with the necessary APIs to get around the unsafe regions of this iphone x. We do this by using the new safeAreaLayoutGuide anchors in our code
safeAreaLayoutGuide

Navigation controller view offsetting on status bar hide on iOS 7

Weird iOS 7 issue I am having.
I have a UINavigationController added as a child view controller to my main view controller.
When I hide the status bar (by setting preferredStatusBarHidden and calling setNeedsStatusBarAppearanceUpdate), the navigation controllers top view controller recesses the 20 pixels that the status bar did, but not the UINavigationBar. This is only happening on iOS 7 - and I cannotfind a work around. If I rotate the device, it corrects the issue?
Before I hide the status bar
After I hide the status bar
I have tried calling layoutIfNeeded and updateViewConstraints. These did nothing. Was able to do conditional checks for version number and add constraints to fix, but this breaks things worse on rotate and I would prefer a cleaner solution if anyone has any ideas.
Thanks.

Storyboard / Navigation Bar issue in Xcode

I'm experiencing a bit of a weird issue and I'm hoping someone can point me in the right direction.
In Xcode, using storyboard, I have a view controller that inherits a navigation bar. This is working fine. Where the issue is is that when I add an element to the view controller (ie, UIButton, UILabel, etc) and run the application on my phone, the Y positioning of the element is off by the amount of the height of the navigation bar.
Let's say I wanted to have a UIButton DIRECTLY BELOW the navigation bar, I would have to move it UNDER the navigation bar, to the very top of the view controller on the Storyboard. On my phone it would be directly below (Y positioning) the Navigation Bar.
I'm fairly new to iOS development, so I'm not even sure where to begin. I tried enabling / disabling Auto Layout, which didn't change anything.
Try this:
Click on your view controller, in the Attributes Inspector uncheck the "Adjust scroll view insets" option.

Move navigation bar in navigation view controller in ios7

I want add 20 points margin to my navigation bar. I need it because I want another background color under status bar as youtube did:
I found
iOS Developer library says: Status bar background appearance provided by the window background, if using UIBarPositionTop.
I found solution for toolbar, but I can't move my navigation bar inside navigation view controller. I just set UIBarPositionTop for my navigation bar, but it changes nothing.
-(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
NSLog(#"position method called");
return UIBarPositionTop;
}
I still see the gray background of status bar instead of white.
Is it possible to do it with a navigation bar or should I use a view with a toolbar?
(XCode 6, development target 7.0+, sdk 8.0, autolayout)
UPDATE: ANOTHER WAY TO RESOLVE PROBLEM
I read this question
and understood, that there is no need to add margin. I added view with background color I need over my navigation bar controller and it resolved my problem.
When you are adding your UIView to the UIWindow, you should change the UIViews size to not underlap the title bar. How to do this is well documented in this post:
Offset on UIWindow addSubview
I hope i understood correctly, look in size inspector, ios 6/7 deltas.
Check this link for an explanation:
Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?

Resources