WWObserve 0.0.2

WWObserve 0.0.2

Maintained by Wayne2Wen.



WWObserve 0.0.2

  • By
  • Wayne2Wen

WWObserve

License MIT  CocoaPods  Support 

Observe whether the subviews are displayed on the screen when the scroll view stops scrolling.

Observe的方法有

  • scrollView代理方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;

- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;
  • scrollView实例方法
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated; 

使用

需要被监测的scrollView

[scrollView ww_registerObserve];

在这个scrollView的需要被监测滚动的subviewww_visibleHandler中写入监测代码

@weakify(self);
view.ww_visibleHandler = ^(CGRect viewRect, CGRect containerRect, BOOL stop) {
    @strongify(self);
    NSString *stopStr = stop ? @"🎈End" : @"🌲Begin";
    NSString *str = [NSString stringWithFormat:@"%zd-%@", self.index, stopStr];
    NSLog(@"%@Scroll\nViewRect:%@, \nContainerRect:%@", str, NSStringFromCGRect(viewRect), NSStringFromCGRect(containerRect));
};

安装

  • CocoaPods安装:

    pod 'WWObserve'
  • 下载ZIP包,将WWObserve资源文件拖到工程中。

其他

本库依赖三方库ReactiveObjC。在使用前,您可以查看示例程序WWObserveDemo