为两个视图设置动画,就像您拨打电话时一样

发布于 2024-12-07 09:26:07 字数 167 浏览 0 评论 0原文

我做了很多尝试,以达到与拨打电话号码时看到的开关效果相同的效果:前视图消失并具有缩放效果,而另一个视图也出现并具有缩放效果。

我达不到那样的效果,总是马马虎虎。似乎有一个规模效应,对不透明度有作用,但是......

你知道如何做到这一点来反映这种效果(不是马马虎虎,我有很多这样的效果)?

I have made many tries to have the same effect of switch than the one you can see when calling a phone number : the front view disapear with a zoom effect, while the other one appears also with a zoom effect.

I can't achieve doing that effect, it's always a so-so. There seems to have a scale effect, with an action on opacity, but...

Do you know how this can be done to reflect that effect (not a so-so, I have tons of those) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

未蓝澄海的烟 2024-12-14 09:26:07
 // Make this interesting.

 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:2.0];
 [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
 [UIView setAnimationDelegate:self]; 
 [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
 self.view.alpha = 0.0;
 self.view.frame = CGRectMake(self.view.center.x,self.view.center.y , 0, 0);
 [UIView commitAnimations];
}

我希望这是一个更好的动画框架。它不能保证有效,但这是我能想到的过渡第一部分的最佳方案。

这将改变视图控制器视图的框架,使其“吸”到屏幕的中心,这是自然的黑色。现在我想起来,CGAffineTransform 会容易得多...

编辑(出于迂腐的缘故):从 iOS 4 开始,您现在可以使用更新的、语法上更干净的动画块和漂亮的转换:

[UIView animateWithDuration:0.25 delay:0.0 options:0 animations:^{
     //animate the toolbars in from the top and bottom
     [myTopView setFrame:CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44)];
     [myBottomView setFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
     //fade to black...
     self.view.alpha = 0.0;
     //and suck inwards.
     self.view.frame = CGRectMake(self.view.center.x,self.view.center.y , 0, 0);
}
completion:^{
    //do something to end nicely, or start another animation block.
}];
 // Make this interesting.

 [UIView beginAnimations:nil context:nil];
 [UIView setAnimationDuration:2.0];
 [UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
 [UIView setAnimationDelegate:self]; 
 [UIView setAnimationDidStopSelector:@selector(startupAnimationDone:finished:context:)];
 self.view.alpha = 0.0;
 self.view.frame = CGRectMake(self.view.center.x,self.view.center.y , 0, 0);
 [UIView commitAnimations];
}

I hope this is a framework for a better animation. It's not guaranteed to work, but it's the best I could think of for the first part of the transition.

This will change the frame of your view controller's view so that it "sucks" itself into the center of the screen, which is a natural black color. Now that I think about it, a CGAffineTransform would have been much easier...

EDIT (For pedantry's sake): Starting with iOS 4, you can now use the newer, and much more syntactically clean, animation blocks and a nice transform:

[UIView animateWithDuration:0.25 delay:0.0 options:0 animations:^{
     //animate the toolbars in from the top and bottom
     [myTopView setFrame:CGRectMake(0, self.view.frame.size.height - 44, self.view.frame.size.width, 44)];
     [myBottomView setFrame:CGRectMake(0, 0, self.view.frame.size.width, 44)];
     //fade to black...
     self.view.alpha = 0.0;
     //and suck inwards.
     self.view.frame = CGRectMake(self.view.center.x,self.view.center.y , 0, 0);
}
completion:^{
    //do something to end nicely, or start another animation block.
}];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文