gpt4 book ai didi

ios - 如何为 Facebook Paper 应用程序的菜单按钮设置动画/变形

转载 作者:可可西里 更新时间:2023-11-01 06:24:37 24 4
gpt4 key购买 nike

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

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

谁能给我解释一下这是怎么做到的?我想要这个用于我的应用程序。

最佳答案

太棒了,以前没见过。

创建了一个执行此操作的快速要点:

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 到直线。玩转动画的数字和选项应该会给您带来不同的体验。

玩得开心!

关于ios - 如何为 Facebook Paper 应用程序的菜单按钮设置动画/变形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22290712/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com