Approximate rect after applying CATransform3D?

2019-08-12 04:52发布

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条回答
看我几分像从前
2楼-- · 2019-08-12 05:26

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:

enter image description here

查看更多
登录 后发表回答