9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UIViewのconvertRect:toView:に関するメモ

Posted at

view0
└ viewA
  └ viewB
という親子構造がある場合(view0内にviewAがあり、その中にviewBがある場合)、
view0に対するviewB相対座標(frame)を取得する方法は次のようなコードになる

CGRect frame = [viewA convertRect:viewB.frame toView:viewA];

あえて、viewAを明記しないで、viewBからの相対で考えると次のような書き方も可能。

CGRect frame = [viewB.superview convertRect:viewB.frame toView:viewB.superview];
9
9
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?