Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get view's frame in UIView that is not superview

I would think this is a simple question, but I cannot seem to find a way to do this.

I have a view that is a subview of my uiviewcontroller. Within that view, I have another view. To clarify, this is the architecture:

>UIViewController.view
--->Subview A
------->Subview B

I want to get the frame of subview b within uiviewcontroller.view.

Is this possible? subviewB.frame gives me the frame of the view within Subview A.

like image 483
Liftoff Avatar asked Jul 13 '13 03:07

Liftoff


1 Answers

Use the UIView convertRect:toView: method:

CGRect frameRelativeToViewControllerView = [subviewB convertRect:subviewB.bounds toView:viewController.view];
like image 110
rmaddy Avatar answered Oct 24 '22 00:10

rmaddy