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

后端 未结 11 1624
遇见更好的自我
遇见更好的自我 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:43

    Here is my answer, this is in swift. This will scroll the pages in scrollview infinitely.

    private func startBannerSlideShow()
    {
    UIView.animate(withDuration: 6, delay: 0.1, options: .allowUserInteraction, animations: {
        scrollviewOutlt.contentOffset.x = (scrollviewOutlt.contentOffset.x == scrollviewOutlt.bounds.width*2) ? 0 : scrollviewOutlt.contentOffset.x+scrollviewOutlt.bounds.width
    }, completion: { (status) in
        self.startBannerSlideShow()
    })
    }
    

提交回复
热议问题