ios - UIView 如何判断自己不在用户的可视范围呢?
PHPz
PHPz 2017-04-18 09:55:01
0
3
669

要求:方案简单易行,用户无感知(不能占用过高的 CPU)
背景:需要封装一个视图控件,该控件需要根据陀螺仪进行频繁的重绘。

目前需要考虑以下情况:

  • alpha

  • hidden

  • 作为UIScrollView 的子视图,被滚动到视图范围外

  • 电话或者进入后台

  • 被其它视图遮挡

PHPz
PHPz

学习是最好的投资!

reply all(3)
迷茫

alpha, hidden——You can know these two UIViews by getting their own properties
UIScrollView subview——You can get the frame of UIView relative to the screen through [scrollView convertRect:self.frame toView:[UIApplication sharedApplication].keyWindow];, and you can also judge whether it is within the view range through specific data
Make a phone call or enter the background - by implementing the corresponding proxy method in appdelegate, a notification will be sent after the proxy method is executed, so that UIView can receive the notification and also know that it is blocked by other views - you can control this thing yourself, write your own app , you will definitely know when the obstruction will occur

阿神

/* Return true if rect2' is contained in rect1', false otherwise. `rect2'
is contained in rect1' if the union of rect1' and `rect2' is equal to
`rect1'. */

CG_EXTERN bool CGRectContainsRect(CGRect rect1, CGRect rect2)

CG_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
巴扎黑

Didn’t you list them all?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!