Approximate rect after applying CATransform3D?

一曲冷凌霜 提交于 2020-01-16 04:10:07

问题


I applied CATransform3D to a view. How can I find its approximate new frame after it?

I mean I applied a complex transform: rotation, translation, scale and perspective. And I need to find something like approximate minimal rect. I need it because this view is added to UIScrollView (to know the contentSize I need and of course to implement "scrollToItem:")


回答1:


If you want to get the CGRect that completely contains this transformed view, you can use convertRect:toView:. For example:

CGRect rect = [viewWithTransforms convertRect:viewWithTransforms.bounds toView:self.view];

For example, the gray view is some transformed UIView, and the black border is the result of convertRect:toView: shown above:



来源:https://stackoverflow.com/questions/31139969/approximate-rect-after-applying-catransform3d

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