CGRectContainsRect(<#CGRect rect1#>, <#CGRect rect2#>);某个区域是否包含另一个区域。返回BOOL值

 CGRectContainsPoint(<#CGRect rect#>, <#CGPoint point#>); 某个点是否在某个区域中。返回BOOL值

 

CGRectIntersection(<#CGRect r1#>, <#CGRect r2#>); 如果两个区域相交,则返回相交区域的Rect

CGRectIntersectsRect(<#CGRect rect1#>, <#CGRect rect2#>);返回一个BOOL值显示两个区域是否相交

 

[self.view convertRect:rect fromView:smallView];

rect本来是以smallView的坐标系计算尺寸。现在改为以self.view的坐标系计算尺寸。然后返回一个新的Rect。

该方法可以用在以下情况。self.view中套了一个view1,view1中套一个view2,view2中套一个view3然后我们想要得到view3在self.view中的rect。

此方法一返回的rect一般origin会变但size不变。因为只是改变了父坐标系。而自身大小没有改变。 

 

[self.view convertRect:rect toView:smallView]; 和上面方法相反。将self.view中的rect坐标系换成smallView中的坐标系。同样返回新rect。

注:以上两个方法中,如果最后一个参数传nil则表示其在窗口中的位置即在keyWindow中的位置。

[self.smallView.superView convertRect:self.smallView.frame toView:nil];

上方的写法是计算smallView在keyWindow中的位置。