Programmatically scroll a UIScrollView to the top of a child UIView (subview) in Swift

后端 未结 11 1553
遇见更好的自我
遇见更好的自我 2020-12-29 03:35

I have a few screens worth of content within my UIScrollView which only scrolls vertically.

I want to programmatically scroll to a view contained somewhere in it\'s

11条回答
  •  有刺的猬
    2020-12-29 03:50

    It is important to point out for any of you beginners out there that you will need to link the UIScrollView from your story board into you code then use the extension ".nameoffunction"

    For example:

    you import your UIScrollView to your code and name it bob.

    you have an extension script written like the one above by "dyson returns"

    you now write in your code:

    "bob.scrollToTop"

    This attached the extension function "scrollToTop" to you UIScrollView in the storyboard.

    Good luck and chin up!

提交回复
热议问题