将UIView的可见矩形添加为子视图 [英] Get Visible rectangle of UIView added as a subview
本文介绍了将UIView的可见矩形添加为子视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如展示在上面的图片UIView A&在UIView B上添加UIView C.对于B ClipToBounds是YES,因此红色区域不可见。
As show in Picture above UIView A & UIView C are Added on UIView B. for B ClipToBounds is YES so the Red area is not visible.
是否可以获得A&的可见矩形C(以行显示)
Is it possible to get Visible rectangle of A & C ( shown with Lines )
我需要在触摸时显示可见区域中的矩形,例如View A.就是这样。
I need show Rectangle in visible area when I touches e.g View A. thats it.
推荐答案
您可以使用 CGRectIntersection()方法
CGRect intersectionRect = CGRectIntersection(viewA.frame, viewB.frame);
if(CGRectIsNull(intersectionRect)) {
//Rects do not intersect
}
这篇关于将UIView的可见矩形添加为子视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文