Disable vertical scroll in UIScrollView Swift

前端 未结 8 2141
情深已故
情深已故 2021-02-15 00:37

(Don\'t mark this question as duplicated. I read a lot of questions but I don\'t find the answer to my issue.)

My issue is the following: I have a UIScrollView

相关标签:
8条回答
  • 2021-02-15 01:10

    Use next class, setting canScroll as needed:

    class BlockScrollView: UIScrollView {
        var canScroll = true
    
        override func setContentOffset(_ contentOffset: CGPoint, animated: Bool) {
            if canScroll {
                super.setContentOffset(contentOffset, animated: animated)
            }
        }
    }
    
    0 讨论(0)
  • 2021-02-15 01:21

    just add single Line

    yourScrollView.bounces = false
    

    and make Sure your scroll view subview(Content) height is equal to you scrollview height And you're Done

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