LoginSignup
38
38

More than 5 years have passed since last update.

UIViewの位置をオフセット指定で動かす

Posted at

CGRectOffset関数を使うとラク。

CGRect CGRectOffset (
   CGRect rect,
   CGFloat dx,
   CGFloat dy
);

dx, dy に rect からの移動量を指定する。
view.frame.origin.x += 100 みたいなことがしたい場合に以下のように書ける。

view.frame = CGRectOffset(view.frame, 100.0, 0.0);
38
38
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
38
38