How to disable horizontal scrolling of UIScrollView?

前端 未结 14 1906
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 08:17

I have a UIView like iPhone\'s Springboard. I have created it using a UIScrollView and UIButtons. I want to disable horizontal scrolli

14条回答
  •  爱一瞬间的悲伤
    2020-12-02 08:39

    Disable horizontal scrolling by overriding contentOffset property in subclass.

    override var contentOffset: CGPoint {
      get {
        return super.contentOffset
      }
      set {
        super.contentOffset = CGPoint(x: 0, y: newValue.y)
      }
    }
    

提交回复
热议问题