要求:方案简单易行,用户无感知(不能占用过高的 CPU)
背景:需要封装一个视图控件,该控件需要根据陀螺仪进行频繁的重绘。
目前需要考虑以下情况:
alpha
hidden
作为UIScrollView 的子视图,被滚动到视图范围外
电话或者进入后台
被其它视图遮挡
迷茫2017-04-18 09:57:01
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
阿神2017-04-18 09:57:01
/* 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);