问题
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