真似て作った実装が早速出てた。なるほどこんな感じかー
サンプルを立ち上げると人の顔が上部に表示される。
これをタップすると顔が中心へつつーっと移動して、下にペロッとビューが開く。
顔アイコンはドラッグして移動できて、左右の端にスナップされる。
移動はバウンスするようになっていて細かい配慮あり。
このバウンスは2段階のアニメーションで実現されている。
CHDraggableView.m
- (void)_snapViewCenterToPoint:(CGPoint)point edge:(CGRectEdge)edge
{
:
[UIView animateWithDuration:0.28f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.center = CGPointIntegral(step1);
} completion:^(BOOL finished){
if (finished) {
[UIView animateWithDuration:0.25f delay:0.0f options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.center = CGPointIntegral(step2);
} completion:^(BOOL finished){}];
}
}];
}
あらかじめ方向を計算しておき、最初のアニメーションで目的位置を行きすぎて、2番目のアニメーションで目的位置に戻すことを行っている。単純だが悪くない。






