Skip to content

nolano/YYViewVisible

Repository files navigation

YYViewVisible

[![CI Status](https://img.shields.io/travis/yuyuan yue/YYViewVisible.svg?style=flat)](https://travis-ci.org/yuyuan yue/YYViewVisible) Version License Platform

功能

一个工具,用来监测view是否可见,以及可见的比例

Example

/// limit: 曝光比例,0-1
YYViewAction *everyTimeAction = [YYViewAction actionWithLimit:0.5 handler:^(YYViewAction * _Nonnull action) {
      if (action.isAnswer) {
          NSLog(@"可见啦");
      }else {
          NSLog(@"不可见啦");
      }
  }];

  /// 此回调为状态改变时回调,当设置callBackTime == 0时,可以与上面的handler配合使用(比如停留需求)
  everyTimeAction.stateUpdateHandler = ^(YYViewAction * _Nonnull action) {
      if (action.isAnswer) {
          NSLog(@"可见啦");
      }else {
          NSLog(@"不可见啦");
      }
  };

  /// 设置为0,每次都会回调,设置为1,则状态改变回调
  everyTimeAction.callBackTime = 0;

  [[YYViewCycle shared] registerView:self.view actions:@[everyTimeAction]];

Requirements

Installation

YYViewVisible is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'YYViewVisible'

Author

yuyuan yue, last_yearv@163.com

License

YYViewVisible is available under the MIT license. See the LICENSE file for more info.

About

A tool to monitor the visibility of the view

Resources

License

Stars

Watchers

Forks

Packages

No packages published