UIScrollView Paging Autolayout & Storyboard

后端 未结 3 674
Happy的楠姐
Happy的楠姐 2020-12-04 12:55

There are plenty of answers regarding scroll views with autolayout and plenty about scrollview paging, but I can\'t find a single thing that addresses both.

I\'m not

3条回答
  •  温柔的废话
    2020-12-04 13:25

    Follow Working with Scroll Views to build paging UIScrollView with content in Interface Builder.

    I'd also recommend using Stack View as a content view for your UIScrollView since it allows to essentially reduce layout complexity.

    When you use traditional approach each entry view inside content view has 5 constraints at least:

    • leading to previous entry
    • top to parent
    • trailing to next entry
    • bottom to parent
    • equal width to scroll view

    Stack View arrange its content automatically thus the only constraint each entry should have is "equal width to scroll view"

    Check this project https://github.com/eugenebrusov/ios-stack-paging-scroll to see Stack View in action.

提交回复
热议问题