Getting Visible Rect of UIView

时光毁灭记忆、已成空白 提交于 2019-12-11 03:35:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!