3

我在 Facebook Paper 应用程序中看到了这个动画/变形,他们会将菜单按钮变形,当你下拉菜单时,变成 X,然后在你点击它时返回。我记录了它,因为我不知道如何以其他方式显示它。

https://www.youtube.com/watch?v=y6j_mVgv-NM

有人可以向我解释这是如何完成的吗?我想要这个用于我的应用程序。

4

1 回答 1

8

太棒了,以前没见过。

创建了一个快速要点:

https://gist.github.com/mnmaraes/9458421

编辑:所以它不仅仅是一个链接,关键概念是两种方法:

-(void)morphToX
{
    CGFloat angle = M_PI_4;
    CGPoint center = CGPointMake(120., 120.);

    __weak TUIViewController *weakSelf = self;
    [UIView animateWithDuration:0.8 delay:0.0 usingSpringWithDamping:0.6 initialSpringVelocity:2.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        TUIViewController *strongSelf = weakSelf;

        strongSelf.topLineView.transform = CGAffineTransformMakeRotation(-angle*5);
        strongSelf.topLineView.center = center;

        strongSelf.bottomLineView.transform = CGAffineTransformMakeRotation(angle*5);
        strongSelf.bottomLineView.center = center;

        strongSelf.centerLineView.transform = CGAffineTransformMakeScale(0., 1.0);

    } completion:^(BOOL finished) {

    }];
}

和:

-(void)morphToLine
{

    __weak TUIViewController *weakSelf = self;
    [UIView animateWithDuration:0.8 delay:0.0 usingSpringWithDamping:0.6 initialSpringVelocity:2.0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        TUIViewController *strongSelf = weakSelf;

        strongSelf.topLineView.transform = CGAffineTransformIdentity;
        strongSelf.topLineView.center = CGPointMake(120., 2.);

        strongSelf.bottomLineView.transform = CGAffineTransformIdentity;
        strongSelf.bottomLineView.center = CGPointMake(120., 238.);

        strongSelf.centerLineView.transform = CGAffineTransformIdentity;

    } completion:^(BOOL finished) {

    }];
}

第一个动画从平行线到 X,第二个从 X 到线。玩转动画的数字和选项应该会给你不同的感觉。

玩得开心!

于 2014-03-10T02:17:28.123 回答