Commit 12651d9d authored by jz's avatar jz

update

parent aa72e943
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
*/ */
+ (UIViewController *)currentControllerForView:(UIView *)view; + (UIViewController *)currentControllerForView:(UIView *)view;
/// 判断当前view是否处于屏幕上
/// @param view 指定view
+ (BOOL)viewIsVisible:(UIView *)view;
/** /**
获取曝光卡片所在的位置 获取曝光卡片所在的位置
*/ */
......
...@@ -114,6 +114,36 @@ ...@@ -114,6 +114,36 @@
otherView.pageCtrl.down_loading_times = self.pageCtrl.down_loading_times; otherView.pageCtrl.down_loading_times = self.pageCtrl.down_loading_times;
} }
/// 判断当前view是否处于屏幕上
/// @param view 指定view
+ (BOOL)viewIsVisible:(UIView *)view {
// 可见
if (!view.window || view.hidden || view.layer.hidden || !view.alpha) {
return NO;
}
UIView *current = view;
while ([current isKindOfClass:[UIView class]]) {
if (current.alpha <= 0 || current.hidden) {
return NO;
}
current = current.superview;
}
// 判断当前View 与 view所在window是否存在交集
CGRect viewRectInWindow = [view convertRect:view.bounds toView:view.window];
BOOL isIntersects = CGRectIntersectsRect(view.window.bounds, viewRectInWindow);
if (isIntersects) {
// 获取View 与 view所在window的相交区域
CGRect intersectRect = CGRectIntersection(view.window.bounds, viewRectInWindow);
if (intersectRect.size.width != 0.f && intersectRect.size.height != 0.f) {
return YES;
}
}
return NO;
}
#pragma mark - GMViewExposureProtocol #pragma mark - GMViewExposureProtocol
- (void)setVisibleView:(BOOL)visibleView { - (void)setVisibleView:(BOOL)visibleView {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment