クロージャの書き直しでハマったので書く。
前提
-
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
);
要点
- 定数が変わる(
UIViewAnimationOptionsCurveEaseOut
→UIViewAnimationOptions.CurveEaseOut
) - クロージャの構文がちがう(
^{
→{() -> Void in
)