On some screens the label inside a StackView partially disappears under the navigation bar. Currently I have a constraint stackView.top = Top Layout Guide.bottom, but it does not seem to work as I hoped. How to constrain my StackView, so that everything would be properly visible?
The problem was solved by embedding the view into navigation controller. After that the constraint started working perfectly.
Related
I made a view for a switch view. Now I already had tabbed menu buttons in it. The problem is the subview for the switch view seems to be overlapping with the tab bar icons at the bottom. Please help.
i think thats because your tabBar is set to translucent. set it to non-translucent from storyboard or programatically.
self.tabBarController.tabBar.translucent = false
You should have a constraint that sets the vertical space between your subview and your tabbar.
Also, check that your layout respects the iPhone X Safe Area (https://developer.apple.com/ios/human-interface-guidelines/overview/iphone-x/), from your image it seems that your elements overlap the safe area at the bottom.
I encountered a problem with the scrolling when using the prefersLargeTitles and added UITableView.
If I set the prefersLargeTitles within a navigation controller and its root is a UITableViewController everything is fine, scrolling of the navigation large title works the same way we can see in the system apps (in iOS 11+).
The problem
However, if I use a UIViewController and add a UITableView in it, scroll seems to act differently. Navigation bar is moving more/faster than I actually scroll. It just hides/shows the large title whenever I scroll into a position that just triggers it, so I end up with the totally different feeling.
Turns out that the layout is causing this problem.
The problem occurs if the UITableView use Align top to: Safe Area constraint (besides the bottom, leading and trailing to Safe Area) and is not extended under the bar.
However if I use the extended layout, align top to the superview, I can still use the UITableView and get the correct behaviour of the large title and its navigation bar.
edgesForExtendedLayout = .top
extendedLayoutIncludesOpaqueBars = true
Or use navigation bar's isTranslucent = true which extends it too.
I have a modal view that I'm presenting over the current view that has a UINavigationBar as a subview. Everything's working great, except that the UINavigationBar doesn't want to behave according to the autolayout constraints. Everything else in the view behaves as desired.
For some reason, the left and right bar button items are cut off on the edges of the view. I inspected the view at runtime to reveal that the total width of the UINavigationBar is the right width, but the bar buttons aren't conforming.
I also checked to make sure I didn't have negative margins or some other anomaly in the constraint definitions.
I have also tried setting the frame of the UINavigationBar manually, but it yielded no improvement.
Problematic View
Constraints
I'd like to keep the UINavigationBar, because it gets styled globally with the rest of my app (as opposed to creating a custom UIView imitation and styling it individually). Does anyone know what handle to jiggle to get the bar button items to conform to the right width?
Say I have a UIViewController and I want to add a red UIView atop it that covers its view completely using Auto Layout.
My first instinct was to pin it to every edge of the view controller's view, but due to the iOS 7 nature of view controller views extending underneath the nav bars, pinning it with a constant of 0 doesn't put it under the nav bars. And if I put -64 to cover it in portrait, that's not the correct constant for landscape as the nav bar is shorter.
How should I be implementing this?
Make sure your view is pinned to the top of the super view, not the top layout guide. It sounds like it's currently pinned to the top layout guide.
If it is pinned to the top layout guide, the best way to fix it is to delete the constraint, select the view, click the "Pin" tool at the bottom right of IB, and then select the top with a setting of zero.
This works fine in Xcode 5.1.1, but was a little buggy in earlier versions. Control+Drag onto the view generally forces you to select the top layout guide instead of the top of the view.
I am using Auto Layout in a storyboard to position a UICollectionView. I have created a vertical spacing between Top Layout Guide and the CollectionView. But the collection view still starts underneath the navigation bar. Even the prototype cell also has extra padding. Please see images below.
Interface Builder:
Simulator View:
The content should start below the navigation bar but as the user scrolls the content should go under the navigation bar. How do I accomplish this?
In your storyboard go to View Controller properties, and make sure that Under Top Bars option is unchecked.
Also in most cases you want to have opaque navigation bar.