You can convert a frame (CGRect
) or a point (CGPoint
) from its superview's coordinate system to another view's coordinate system. All these methods are instance methods of UIView
For example:
let convertedRect = superview.convertRect(subview.frame, toView: anotherView)
In your case, you might try something like this:
let cRect = keyboardAccessoryView.convertRect(accessorySubview.frame, toView: self.view)
Note that this will convert the subview (whose frame
is in the keyboardAccessory's coordinate space) to the current viewController's view's coordinate system.
If you want it in terms of the entire screen, try this:
let coordinateSpace = UIScreen.mainScreen().coordinateSpace
kbAccessoryView.convertRect(subview.frame, toCoordinateSpace: coordinateSpace)