Whiteline issues while popping from view controller - ios

My case navigation bar color different for two controllers. When I pop from a second view controller to first one there is white line glitch in UI appears. I don't understand why issues happen, is set navigation bar shadow image to nil and use a background image for setting navigation bar background.

one reason that can cause this, is extra content from other screens overlapping each other..
try to set each view controller to have
clipsToBounds = true
See Description from Apple...
Setting this value to true causes subviews to be clipped to the bounds
of the receiver. If set to false, subviews whose frames extend beyond
the visible bounds of the receiver are not clipped. The default value
is false.
another cause is, some view controller has a background with clear color...
make sure each view controller has a non clear background.
EDIT
the question was not clear enough, it looks like I didn't understand well, try to change the tint color of navigation bar to clear.

Finally, I found my issues, issues are when I am setting a navigation bar from orange to white I set the translucent property of the navigation bar is true. which cause the problem for me to display a white line.

Related

Set navigationbar size according to background image

I have set an backgroundImage for my navigationbar. This works fine. But I would like to have the navigationbar height to be adjusted to the background image. At the moment the width of the background images is also not set according to the screen size.
I tried setting the height of the navigationbar like described here. This shows a bigger navigationbar for like a second but then it shrinks to its default size again.
Does anyone know how to achieve what I want? Here is an example of what I want to achieve: image
Apple Documentation:
It is permissible to customize the appearance of the navigation bar
using the methods and properties of the UINavigationBar class but you
must never change its frame, bounds, or alpha values or modify its
view hierarchy directly.
To achieve the effect seen in the image you tagged, they are most likely using a collection view to layout their data and that image is part of the collection view's header. They made the navigation bar background color clear, but the image is definitely not part of the navigation bar itself.
Apple recommends to never change the frame of a navigation bar manually because it messes with the layout code of its subviews and animation methods.
You could either subclass the navigation bar and attempt to create something similar, or go the easier route and make the navigation bar clear (UIColor(white: 0, alpha: 1) not .clear otherwise it might show up incorrectly) and have an underlying view display the image (e.x. a collection view whos header extends to the top of the view controller).
This will allow you to adjust the image height and width freely without subclassing the navigation bar, and creating potential bugs.
You can make custom NavigationBar class.
It can be help you
https://developer.apple.com/library/archive/samplecode/NavBar/Introduction/Intro.html#//apple_ref/doc/uid/DTS40007418-Intro-DontLinkElementID_2

Update positionForBar for toolbar

In my app I use a toolbar on the top because it lays out bar button items better for what I need, and I set the toolbars delegate to the view controller and tell it to be top attached. I also have a setting that will hide the status bar, so the issue that is happening is that when the status bar is set to hidden, and the app is closed and then re-opened, positionForBar is called but since there is no status bar, it doesn't do anything to the toolbar, so when I turn the status bar back on the app looks strange, and the toolbar is 20px down, and the status bar is showing but there is no background to the status bar, so it looks strange. positionForBar is being called still though but for some reason I need to close the app again before the toolbar will draw behind the status bar again. I have found out that if I remove the toolbar from the superview and re-add it again, it will draw behind the status bar, or i can remove positionForBar and have my own view be the background for the status bar, my old issue with this solution is that it won't be transparent (I could maybe put a 20px toolbar there though maybe?) and my problem with removing it and re-adding the view is then I will need to move a ton of my code around because remove it and re-adding it messes with constraints so I will need to fully reconstruct the entire view just for it to redraw behind the status bar. Is there a way to just refresh the view or something? I have tried setNeedsLayout and setNeedsDisplay and nothing really works for it to redraw besides removing and re-adding
Try manually setting the UIToolbar's frame:
topToolbar.frame = CGRectZero
Or updating the constraints, either will cause the UIToolbar to update its attachment.

Clear background for status bar in iOS

How can I set the colour of the status bar to be clear. No matter what I do, it is white with some alpha.
I do not want it to disappear and I want the text to be black.
In the picture it might look like nag bar and status bar are grey but actually both are white with some blur affect or nag bar has blur affect and status bar is clear.
Here is what I get despite the clear status bar background colour
The status bar has no background since iOS 7. In other words, it's clear by default.
If you see it white, it means the underlying view is white, and you need to change that.
I was having the same problem. It ended up that my view was constrained to the top layout guide when instead it should have been constrained to the superview. Even though the view is constrained to different points it will look the same in interface builder (in my case, I think this is because I was instantiating the viewcontroller to my navigation controller in code and not displaying the navbar). See the image below.
Click on the constraints for the imageview in the view above and the difference in constraints can be seen in the size inspector.
Constraining to the superview will look like this:
This results in the simulator displaying the view like this:
Notice how the status bar is clear and overlaid on top of the imageview.
Constraining to the top layout guide will look like this:
This results in the simulator displaying the view like this:
Notice how the status bar appears white and how the imageview seems constrained to the status bar (the status bar is white text on a white background fyi).
So, in order to fix this problem, you need to change the constraint of the image view to be constrained to the superview.
You change this by selecting the constraint in this list:
Once you have the constraint selected you can change what the constraint is attached to over here:

dimmed area missplacement when using UISearchDisplayController with translucent navigation bar

When I switch navigationBar to translucent, my UISearchDisplayController went crazy.
The dimmed area is missplaced by 64px, same for first row in results table.
I know how to fix resultTableView missplacement, but I cannot find a way to fix dimmed area frame.
Strangely enough I found that my main view is in origin.y = 64.0f when translucent is set to YES.
It happens somewhere in between viewDidLoad, viewDidAppear. If I change it it works, but than transitions between views in navigations controller are broken.
=============
Problem solved by: extendedLayoutIncludesOpaqueBars
Check the search bar's AutoLayout/AutoResizingMask settings.
Also make sure you're not manually modifying the bar's frame as the system will try to animate the bar into its position along the dimmed view and results' table view.
When you set the translucent property and automaticallyAdjustsScrollViewInsets to YES (default): a) the view gets stretched under the navigation bar and b) a top contentInset is added to the underlying UIScrollView (table view is a subclass).
My guess is that only b) is happening in your case for some reason. You can try to solve it by either:
Clear automaticallyAdjustsScrollViewInsets.
Removing the automatically added contentInset from your scroll view.
Setting your controller to do a) even with opaque bars by setting extendedLayoutIncludesOpaqueBars.

iOS ChildViewController in UINavigationController = show StatusBar

I have stumbled across a weird problem when implementing a view container which is connected with child view controllers.
The hierarchy is the following:
I have a UISplitViewController and in the MasterViewController I added a view container which is connected to a UIViewController which is embedded in a UINavigationController.
The outcome is the following:
The ChildViewController leaves a white space at the top which seems to be exactly as high as the status bar. How can I avoid that the status bar frame is shown in the child view controller?
I tried to set wantsFullScreenLayout for the ChildViewController and for its UINavigationController but it doesn't change anything.
I also tried to set the y offsets of the views to -20.0 points but that ends up in another problem.
Only when I set status bar hidden for the application it is not shown for the ChildViewController but that in turn also hides the status bar at the top of the UISplitViewController.
Would be glad for some hints.
Basically it looks like the top gap is the status bar. The statusbar at the moment is 'light' colored which is why it's not showing on top of the white background. Try changing the background color of the view controller to black or use one of the appearance callbacks to change the status bar to a darker color.

Resources