获取 UIView 的可见矩形 [英] Getting Visible Rect of UIView

查看:36
本文介绍了获取 UIView 的可见矩形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设 UIView 仅沿着边缘(没有其他视图在中间的某个地方将其分解)?

What's the simplest method to get the visible rect of any arbitrary UIView as a CGRect, assuming that the UIView is only clipped along the edges (no other views breaking it up somewhere in the middle)?

为了清楚起见,此方法不应仅检索相对于视图的超视图的可见矩形.但至少相对于它的所有祖先,理想情况下也相对于所有兄弟姐妹.

For clarity, this method should not only retrieve the visible rect relative to the view's superview. But relative to all it's ancestors at a minimum and ideally relative to all siblings as well.

推荐答案

试试这个!

CGRect visibleRect = CGRectIntersection(self.frame, superview.bounds);

这篇关于获取 UIView 的可见矩形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆