UIScrollView and Constraints

后端 未结 1 835
故里飘歌
故里飘歌 2020-11-27 22:37

I\'m trying to place a UIImageView at the top of a UIScrollView and when I constrain the UIScrollView to the sides of the View Controller and constrain the UIImageView to th

相关标签:
1条回答
  • 2020-11-27 23:08

    Check that following constraints are added to your view:

    1. Go to Storyboard -> Select your view
    2. Now at right-bottom corner you can see small buttons to add constraints
    3. Select "Pin" button
    4. And mark all 4 constraints for all sides
    5. Add all 4 constraints to your view

    EDIT

    I have created one demo as you described.

    ImageConstraint Demo

    Set all constraints for UIScrollView and UIImageView and works perfectly.

    Below are reference images for you.

    Storyboard:

    enter image description here

    FOLLOW BELOW STEPS

    Step - 1 : In storyboard Select UIView -> Editor -> Resolve layout issues

    enter image description here

    Step - 2 : Repeat same to add constraint

    enter image description here

    Step - 3 : Select UIScrollView and add constraint from right-bottom corner

    enter image description here

    Step - 4 : Select UIImageView and add constraint for it.

    enter image description here

    0 讨论(0)
提交回复
热议问题