0

I did this for bouncing effect in my view. I have a UIViewController, I am placing scrollview in it and a content view (UIView) in scrollview. I have a "LETS GO" button (to go to next screen) at the bottom of content view. I wanted the content view to have height equal to height of UIViewController view's height. I did assign constraint from storyboard but the problem is, the Content View always has height greater than I expect, the button is hidden under the bottom of iPhone X screen, so that I always have to scroll to get that button in view. This is a problem due to safe area of iPhone X.

I tried to add constraint programmatically by reducing safe area's padding in height of UIViewController's view. But when I rotated screen, the problem existed. I want this to be solved from storyboard. How can I solve this issue?

enter image description here enter image description here

Bibek
  • 3,689
  • 3
  • 19
  • 28
  • you already added in Scrollview, it means it add scroller when content is bigger. if you want to acheive your expected behaviour, add constraint in story board with safe area, and for landscape you have to add constraint with your top and bottom with safe area – Muhammad Shauket Aug 10 '18 at 06:29

1 Answers1

0

I hope this is what you are asking for. When I'm adding scroll view, I do it like this: I place scroll view in the main vc's view, pin it to the Safe Area, then place UIView inside scroll view and pin it to the superview (so scroll view, see screenshot). It's good to work in iPhone X view in storyboard as you have more control where you pin the scroll view. Then I ctrl-drag from content view to vc's main view and do Equal widths, and ctrl-drag from content view to Safe Area and do Equal Heights, and change the priority of the constraint to 250 (in order to scroll vertically).

enter image description here

jonaszmclaren
  • 2,459
  • 20
  • 30