问题
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:
Try this!
CGRect visibleRect = CGRectIntersection(self.frame, superview.bounds);
来源:https://stackoverflow.com/questions/29311554/getting-visible-rect-of-uiview