可以通过以下属性启用或禁用阻力
/**
* This flag defines whether or not resistance is enabled on the scroll view.
* If this is set to NO, both @c resistanceFactor and @c resistanceProgressionRatio
* remain unused. Otherwise, if set to YES, resistance is applied based on those two values.
*/
@property (nonatomic, assign) IBInspectable BOOL shouldApplyResistance;
启用时,使用 resistanceFactor
和 resistanceProgressionRatio
应用阻力
/**
* This property defines the base value of how resistant the scroll view is when
* performing overscroll operations. Please look at @c resistanceProgressionRatio
* in order to achieve progressive resistance during an overscroll operation.
*/
@property (nonatomic, assign) IBInspectable CGFloat resistanceFactor;
/**
* This property affects how much more resistant the scroll view becomes as the user
* continues performing overscroll operations. If this value is 0 the resistance will
* be defined solely by @c resistanceFactor and it will remain the same throughout
* the overscroll operation; otherwise, it will impact how much resistance is seen
* when overscrolling.
*
* Values between 0 and 1 seem to work best with the current implementation.
*/
@property (nonatomic, assign) IBInspectable CGFloat resistanceProgressionRatio;
还可能定义一个执行块,每次调用 UIScrollView
的代理方法 scrollViewDidScroll:
时都会执行此块。该块在应用阻力后执行,以便在运行块时调整 contentOffset
值
/**
* If defined, this block is run every time the scroll view's delegate method
* @c scrollViewDidScroll: is called. Since this class sets itself as the scroll
* view's delegate, this may be used when external code needs to be executed.
*/
@property (nonatomic, copy) void (^scrollViewDidScrollExecutionBlock)(UIScrollView *);
如果此类使用的需要实现 UIScrollView
的代理方法以执行其他任务,它们可以通过设置代理来执行。 EAResistantScrollView
将负责将任何代理调用重定向到适当的对象。
要运行示例项目,请先克隆仓库,然后从 Example 目录运行 pod install
导入
#import <EAResistantScrollView/EAResistantScrollView.h>
Edgar Antunes
EAResistantScrollView 可在 MIT 许可协议下使用。有关更多信息,请参阅 LICENSE 文件。