简体   繁体   中英

How to check an UIImageView is out of the visible area of the UIScrollView?

In the UIScrollView, it holds numerous UIImageView objects.

How to check an UIImageView is out of the visible area of the UIScrollView ?

Can an UIImageView observe itself for moving away from the visible area ?

Thanks.

CGRect visibleRect;
visibleRect.origin = scrollView.contentOffset;
visibleRect.size = scrollView.bounds.size;

BOOL imageViewIsVisible = CGRectIntersectsRect(visibleRect, imageView.frame);

You can observe it in UIScrollViewDelegate's scrollViewDidScroll: method

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM