Why is my UINavigationBar hidden behind the top navigation bar in iMessage? - ios

I have an iMessage extension and I want to make a UI with a UINavigationBar on top. I made a UINavigationBar via a UINavigationController in the storyboard. The bar looks fine in compact presentation style but when I switch to expanded it gets hidden behind the top bar in iMessage. I have had this issue in the past and resolved it by setting the top space to top layout guide to 0. However, I don't think I can constrain a UINavigationBar. Any advice?

Related

Can I add a bottom padding to iOS UINavigationBar to alter the visual height of the bar?

I’m implementing a design that requires the navigation bar to visually appear to be 64px tall (even though the content fits inside the standard height). The standard UINavigationBar height on iOS is 44px and it is strongly discouraged try to to change the that (see: https://developer.apple.com/forums/thread/88202?answerId=274620022#274620022).
So, what I’m trying to do instead is to add a padding of 10px both above and below the bar itself, but I can’t figure out if this is even possible.
I am able to extend the bar by 20px by setting the UINavigationController’s additionalSafeAreaInsets.top = 20, but the bottom of the navigation bar is still flush with the bottom of the navigation controller, and I need it to be -10px from bottom.
So, my question, is this possible, or am I chasing a ghost here?
EDIT: To clarify, I want it to look like how the navigation bar looks in the iMessage conversation view, i.e. a tall navigation bar, but with vertically centered content.
I think you should make a customized navigation bar to solve this issue.
Because built-in UI is not easier to adjust or customize. I have tried many tricks but they didn't work.
I already made a base screen that automatically adds a navigation bar on top, just need to set left/right button and the label. This navigation bar is just a normal UIView.

How to add navigation bar button without using navigation controller from storyboard?

I'm having issues adding navigation bar button to a UINavigationBar directly without using UINavigationController.
The way it appears when using with UINavigationController on iPhoneX, is different from what it looks when i directly add an UINavigationBar.
Even if i set the height of navigationBar manually, the background color and bar button still stick to the top.
Using UINavigationBar
After adjusting height or even using SafeAreaInset to set bar height
using UINavigationController -> desired result

UIView Under Nav and Tab Bars

Using storyboard and Swift, I have a view controller which has two elements on it. A UITextField, and a UIView, which I use merely to give a colored border to the UITextField. The UITextField is a child of the UIView. See:
The problem I am having is that despite having set the top bar and bottom bar simulated metrics attributes to Opaque Navigation Bar and Opaque Tab Bar respectively, See:
When the app builds and runs the top of the UIView is always underneath the nav bar. My over all feeling is that this is somehow a constraints issue but I have not been able to find the solution to it. How do I set the constraints so that the UIView is always immediately underneath the nav bar, and the bottom of the view is always just on top of the tab bar?
Select your UIView in storyboard and assign constraints to the top margins and to bottom margins. There is a 'Pin' button you use to do this that looks something like a Tie-Fighter ship in Star Wars, it is located at the bottom right of your storyboard view.
This will set margins to stretch to top and bottom always.
That is what the layout guides are for. Pin the top to the Top Layout Guide and the bottom to the Bottom Layout Guide. The guides will always move to adjust for any top and bottom bars.

Xcode uiscrollview shows up behind nav bar in IB

Trying to set up a scrollview in a UIViewController that has a nav bar. In IB my content gets pushed up to the top below the nav bar (see image).
When running the app on my phone the view is pushed down to sit below the nav bar which is fine. Is there anyway to get it to reflect like this in IB. It is hard to set up my content when half of it is cut off.
If I add a constraint to make the top of the view sit below the nav bar when I run the app it adds that offset and doesn't look correct. (I guess I could alter the constraint before running on my phone but seems like a ridiculous hack just to layout my app). (Already having major issues getting my scrollView to work the way I want it to... don't scroll if my content fits the screen but also use the scroll view to move the view up if the content is covered up by the keyboard but thats for another post)
when I run in simulator looks like this
In Interface Builder you should make sure your NavigationBar is set to Opaque in the simulated metrics. When you have a transparent Nav bar content can go underneath it.
It might look right in your app if you have a global attribute applied to make sure all nav bars are not translucent.

How to give automatically top space to navigation bar in ios?

I have a UIViewController. I am designing the screen for iPhone 5s. I have a UIImageView & I am giving top space to container of 20. I also have UINavigationBar at top.So the space given of 20 is not enough. UIImageView is hidden behind the UINavigationBar. I can resolve this issue by giving much space from top. But in that case at design time my UI will not look proper. So is there any way by which space from UINavigationBar is automatically calculated?
In Attribute Inspector set Top Bar to Translucent Navigation Bar like this
then set Top Space of imageView to Top Layout Guide like,
set navigation bar type as opaque Navigation Bar so it will opaque that much space from your view controller and show your view content after navigation bar space they will not hide inside of navigation bar.
but if you set navigation bar type as Translucent Navigation bar then your content will hide inside of navigation bar so set "Opaque Navigation Bar" type. no need to do any other stuff for that.
I hope it will help you!

Resources