Edgesforextendedlayout scrollview

By: welle On: 20.07.2017

So my UIViewController is embedded in a navigation controller. I programatically add the navigation buttons and now trying to add a scrollView below this navigation bar.

The problem I'm having is this is filling the full frame size and going under the navigation bar.

While Clafou's answer is certainly correct, if you don't need transparency and want to start under navigation bar, the really proper way is to change behavior of the ViewController so it fits the content properly. To do that, you have two options:. There is great answer for that already on SO so I won't cover it here.

While using auto-layout , just make sure that you give the top-constraint of UIScrollView with Top Layout Guide , not with superview of scroll view. Use the contentInset property of your UIScrollView. For example if you want a gap of 44 points at the top:.

By posting your answer, you agree to the privacy policy and terms of service.

Stack Overflow Questions Developer Jobs Documentation beta Tags Users. Sign up or log in to customize your list.

How to stop your view going under the navigation bar using edgesForExtendedLayout - free Swift 3 example code

Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us.

Log In Sign Up. Join the Stack Overflow Community.

Stack Overflow is a community of 7. Join them; it only takes a minute: Swift iOS Set scrollView constraint below navigation bar programatically Ask Question. How do I programatically set constraints of this scrollview?

CGRectMake 0, 0, , 21 label. To do that, you have two options: Jiri Trecak 3, 11 Exactly what i needed and managed to find out how to do this programatically too. Ravi Sisodia 2 Can you please explain the difference? Or where can I see visual documentation on this matter? For example if you want a gap of 44 points at the top: But say the navigation bar on a iphone5 is 44 points will this still work on an iphone 6 at 44 points?

The navigation bar in portrait is the same height on all devices I believe, but hardcoding as per above sure isn't nice. Instead you can measure your navigation bar and status bar if present and use that for your inset. The best place for that is in viewDidLayoutSubviews.

How to remove the unexpected padding on the header of a UITableView

In Objective-C I usually set the 'edgesForExtendedLayout' Property to UIRectEdgeNone: Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Stack Overflow works best with JavaScript enabled. MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3.

Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Rating 4,4 stars - 914 reviews
inserted by FC2 system