Getting Visible Rect of UIView

2019-07-21 03:50发布

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.

1条回答
淡お忘
2楼-- · 2019-07-21 04:16

Try this!

CGRect visibleRect = CGRectIntersection(self.frame, superview.bounds);
查看更多
登录 后发表回答