eonil
eonil

Reputation: 86155

Is there a convenient method converting `CGRect` from screen-space into specific view-space or vice-versa?

There are predefined methods converting coordinates between

  1. UIView <-> UIWindow
  2. UIWindow <-> UIScreen

How about UIView <-> UIScreen? Is there predefined method in UIKit? I can make my own, however I want to use if there is predefined one.

Upvotes: 2

Views: 1877

Answers (1)

Anomie
Anomie

Reputation: 94844

Yes, UIView has the conventiently-named convertRect:toView: and convertRect:fromView: methods. See the documentation for details.

Note that [A convertRect:rect fromView:B] and [B convertRect:rect toView:A] are basically equivalent, unless A or B is nil.

Upvotes: 1

Related Questions