Get view's frame in UIView that is not superview

frame, ios, objective-c, uiview

Solution

Use the `UIView convertRect:toView:` method:

CGRect frameRelativeToViewControllerView = [subviewB convertRect:subviewB.bounds toView:viewController.view];

Problem

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`.

Original source