How to always makes a UIScrollView scrollable?

前端 未结 2 599
梦如初夏
梦如初夏 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: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

提交回复
热议问题