UIScrollView(FWUIKit)

@interface UIScrollView (FWUIKit)

/// 判断当前scrollView内容是否足够滚动
@property (nonatomic, assign, readonly) BOOL fw_canScroll NS_REFINED_FOR_SWIFT;

/// 判断当前的scrollView内容是否足够水平滚动
@property (nonatomic, assign, readonly) BOOL fw_canScrollHorizontal NS_REFINED_FOR_SWIFT;

/// 判断当前的scrollView内容是否足够纵向滚动
@property (nonatomic, assign, readonly) BOOL fw_canScrollVertical NS_REFINED_FOR_SWIFT;

/// 当前scrollView滚动到指定边
- (void)fw_scrollToEdge:(UIRectEdge)edge animated:(BOOL)animated NS_REFINED_FOR_SWIFT;

/// 是否已滚动到指定边
- (BOOL)fw_isScrollToEdge:(UIRectEdge)edge NS_REFINED_FOR_SWIFT;

/// 获取当前的scrollView滚动到指定边时的contentOffset(包含contentInset)
- (CGPoint)fw_contentOffsetOfEdge:(UIRectEdge)edge NS_REFINED_FOR_SWIFT;

/// 总页数,自动识别翻页方向
@property (nonatomic, assign, readonly) NSInteger fw_totalPage NS_REFINED_FOR_SWIFT;

/// 当前页数,不支持动画,自动识别翻页方向
@property (nonatomic, assign) NSInteger fw_currentPage NS_REFINED_FOR_SWIFT;

/// 设置当前页数,支持动画,自动识别翻页方向
- (void)fw_setCurrentPage:(NSInteger)page animated:(BOOL)animated NS_REFINED_FOR_SWIFT;

/// 是否是最后一页,自动识别翻页方向
@property (nonatomic, assign, readonly) BOOL fw_isLastPage NS_REFINED_FOR_SWIFT;

/// 快捷设置contentOffset.x
@property (nonatomic, assign) CGFloat fw_contentOffsetX NS_REFINED_FOR_SWIFT;

/// 快捷设置contentOffset.y
@property (nonatomic, assign) CGFloat fw_contentOffsetY NS_REFINED_FOR_SWIFT;

/// 内容视图,子视图需添加到本视图,布局约束完整时可自动滚动
@property (nonatomic, strong, readonly) UIView *fw_contentView NS_REFINED_FOR_SWIFT;

/**
 设置自动布局视图悬停到指定父视图固定位置,在scrollViewDidScroll:中调用即可
 
 @param view 需要悬停的视图,须占满fromSuperview
 @param fromSuperview 起始的父视图,须是scrollView的子视图
 @param toSuperview 悬停的目标视图,须是scrollView的父级视图,一般控制器self.view
 @param toPosition 需要悬停的目标位置,相对于toSuperview的originY位置
 @return 相对于悬浮位置的距离,可用来设置导航栏透明度等
 */
- (CGFloat)fw_hoverView:(UIView *)view
         fromSuperview:(UIView *)fromSuperview
           toSuperview:(UIView *)toSuperview
            toPosition:(CGFloat)toPosition NS_REFINED_FOR_SWIFT;

/// 是否开始识别pan手势
@property (nullable, nonatomic, copy) BOOL (^fw_shouldBegin)(UIGestureRecognizer *gestureRecognizer) NS_REFINED_FOR_SWIFT;

/// 是否允许同时识别多个手势
@property (nullable, nonatomic, copy) BOOL (^fw_shouldRecognizeSimultaneously)(UIGestureRecognizer *gestureRecognizer, UIGestureRecognizer *otherGestureRecognizer) NS_REFINED_FOR_SWIFT;

/// 是否另一个手势识别失败后,才能识别pan手势
@property (nullable, nonatomic, copy) BOOL (^fw_shouldRequireFailure)(UIGestureRecognizer *gestureRecognizer, UIGestureRecognizer *otherGestureRecognizer) NS_REFINED_FOR_SWIFT;

/// 是否pan手势识别失败后,才能识别另一个手势
@property (nullable, nonatomic, copy) BOOL (^fw_shouldBeRequiredToFail)(UIGestureRecognizer *gestureRecognizer, UIGestureRecognizer *otherGestureRecognizer) NS_REFINED_FOR_SWIFT;

@end

Undocumented

  • 判断当前scrollView内容是否足够滚动

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL fw_canScroll;
  • 判断当前的scrollView内容是否足够水平滚动

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL fw_canScrollHorizontal;
  • 判断当前的scrollView内容是否足够纵向滚动

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL fw_canScrollVertical;
  • 当前scrollView滚动到指定边

    Declaration

    Objective-C

    - (void)fw_scrollToEdge:(UIRectEdge)edge animated:(BOOL)animated;
  • 是否已滚动到指定边

    Declaration

    Objective-C

    - (BOOL)fw_isScrollToEdge:(UIRectEdge)edge;
  • 获取当前的scrollView滚动到指定边时的contentOffset(包含contentInset)

    Declaration

    Objective-C

    - (CGPoint)fw_contentOffsetOfEdge:(UIRectEdge)edge;
  • 总页数,自动识别翻页方向

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSInteger fw_totalPage;
  • 当前页数,不支持动画,自动识别翻页方向

    Declaration

    Objective-C

    @property (nonatomic) NSInteger fw_currentPage;
  • 设置当前页数,支持动画,自动识别翻页方向

    Declaration

    Objective-C

    - (void)fw_setCurrentPage:(NSInteger)page animated:(BOOL)animated;
  • 是否是最后一页,自动识别翻页方向

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL fw_isLastPage;
  • 快捷设置contentOffset.x

    Declaration

    Objective-C

    @property (nonatomic) CGFloat fw_contentOffsetX;
  • 快捷设置contentOffset.y

    Declaration

    Objective-C

    @property (nonatomic) CGFloat fw_contentOffsetY;
  • 内容视图,子视图需添加到本视图,布局约束完整时可自动滚动

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly) NS_REFINED_FOR_SWIFT UIView *fw_contentView;
  • 设置自动布局视图悬停到指定父视图固定位置,在scrollViewDidScroll:中调用即可

    Declaration

    Objective-C

    - (CGFloat)fw_hoverView:(nonnull UIView *)view
              fromSuperview:(nonnull UIView *)fromSuperview
                toSuperview:(nonnull UIView *)toSuperview
                 toPosition:(CGFloat)toPosition;

    Parameters

    view

    需要悬停的视图,须占满fromSuperview

    fromSuperview

    起始的父视图,须是scrollView的子视图

    toSuperview

    悬停的目标视图,须是scrollView的父级视图,一般控制器self.view

    toPosition

    需要悬停的目标位置,相对于toSuperview的originY位置

    Return Value

    相对于悬浮位置的距离,可用来设置导航栏透明度等

  • 是否开始识别pan手势

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) BOOL (^) (UIGestureRecognizer *_Nonnull __strong) fw_shouldBegin;
  • 是否允许同时识别多个手势

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) BOOL (^) (UIGestureRecognizer *_Nonnull __strong, UIGestureRecognizer *_Nonnull __strong) fw_shouldRecognizeSimultaneously;
  • 是否另一个手势识别失败后,才能识别pan手势

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) BOOL (^) (UIGestureRecognizer *_Nonnull __strong, UIGestureRecognizer *_Nonnull __strong) fw_shouldRequireFailure;
  • 是否pan手势识别失败后,才能识别另一个手势

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) BOOL (^) (UIGestureRecognizer *_Nonnull __strong, UIGestureRecognizer *_Nonnull __strong) fw_shouldBeRequiredToFail;