How to always makes a UIScrollView scrollable?

前端 未结 2 601
梦如初夏
梦如初夏 2021-02-05 02:37

I have a UIScrollView. The scrollview.contentSize is set to the height of all subviews in the UIScrollView. When the height of the c

相关标签:
2条回答
  • 2021-02-05 02:42

    In swift:

    scrollView.alwaysBounceVertical = true
    scrollView.alwaysBounceHorizontal = true
    
    0 讨论(0)
  • 2021-02-05 02:55

    There are two properties on UIScrollView that sound like what you want:

    @property(nonatomic) BOOL alwaysBounceVertical; // default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag vertically
    @property(nonatomic) BOOL alwaysBounceHorizontal; // default NO. if YES and bounces is YES, even if content is smaller than bounds, allow drag horizontally
    

    Simply set one or both of them to YES and you will get the bounce effect.

    This can also be set in IB by checking the "Bounce Horizontally" and/or "Bounce Vertically" box(s):

    enter image description here

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