LoginSignup
9
9

More than 5 years have passed since last update.

animateWithDurationビフォーアフター

Posted at

クロージャの書き直しでハマったので書く。

前提

  1. arrowは画像にアウトレット接続していること

Before

[UIView animateWithDuration:0.5
          delay:0.0
          options:UIViewAnimationOptionCurveEaseOut
          animations:^{
              _arrow.center = CGPointMake(pt.x, pt.y - height/2);
          }
          completion:nil];

After

UIView.animateWithDuration(
          0.5,
          delay:0.3,
          options:UIViewAnimationOptions.CurveEaseOut,
          animations: {() -> Void in
              self.arrow.center = CGPoint(x:pt.x, y:pt.y - height/2)
          },
          completion: nil
      );

要点

  • 定数が変わる(UIViewAnimationOptionsCurveEaseOutUIViewAnimationOptions.CurveEaseOut
  • クロージャの構文がちがう(^{{() -> Void in
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