
// Assuming button 1 was clicked...[UIVIEw animateWithDuration:0.25f delay:0.0f options:UIVIEwAnimationoptionCurvelinear animations:^(voID) { self.button2.frame = CGRectOffset(self.button2.frame,0.0f,20.0f); self.button3.frame = CGRectOffset(self.button3.frame,20.0f); } completion:^(BOol finished) { NSLog(@"Finished"); }]; 如果我增加动画持续时间,例如从0.25到0.75,按钮不会保持在一起,但它们会以不同的时间间隔开始移动.我已经尝试过使用Core Animation方法,通过对动画和其他内容进行分组,但还没有找到任何解决方案.
你有什么想法?现在我将持续时间保持在0.25,直到我拿出一些东西.
解决方法 一种解决方案是将button2和button3都设置为另一个UIVIEw中的子视图,并分别为每个按钮设置动画而不是每个按钮.这是否是一种好的方法取决于您使用堆叠按钮尝试完成的任务.编辑:
由于我的经验是块内的动画是同步的,我实现了如下所示的代码.我为动画持续时间(0.15,0.25,0.75,1.25)尝试了很多值,而button2和button3正在同步移动(因为button2位于button3的顶部,我实际上根本看不到button3,直到我点击button2,导致button3从按钮3下方移动.
- (IBAction)button1Tapped:(ID)sender { NSLog(@"button1Tapped..."); [UIVIEw animateWithDuration:0.75f delay:0.0f options:UIVIEwAnimationoptionCurveEaSEOut animations:^(voID) { self.button2.frame = CGRectOffset(self.button2.frame,20.0f); self.button3.frame = CGRectOffset(self.button3.frame,20.0f); } completion:^(BOol finished) { NSLog(@"Finished"); }];}- (IBAction)button2Tapped:(ID)sender { NSLog(@"button2Tapped..."); [UIVIEw animateWithDuration:0.75f delay:0.0f options:UIVIEwAnimationoptionCurveEaSEOut animations:^(voID) { self.button3.frame = CGRectOffset(self.button3.frame,20.0f); } completion:^(BOol finished) { NSLog(@"Finished"); }];}- (IBAction)button3Tapped:(ID)sender { NSLog(@"button3Tapped...");} 总结 以上是内存溢出为你收集整理的ios – 同时动画多个UIViews全部内容,希望文章能够帮你解决ios – 同时动画多个UIViews所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)