如何使用的UIView animateWithDuration比例适当的UIImageView? [英] How to scale UIImageView properly with UIView animateWithDuration?

查看:185
本文介绍了如何使用的UIView animateWithDuration比例适当的UIImageView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我缩放的UIImageView,然后使用UIView的animateWithDuration与UIViewAnimationOptionAutoreverse选项恢复它。问题是图像动画是在动画的最后一点点锯齿(抽搐)。这里是我的code:

I'm scaling UIImageView and then reverting it using UIView animateWithDuration with UIViewAnimationOptionAutoreverse option. The problem is the image animation is a little bit jaggy (twitching) at the end of the animation. Here's my code:

[UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionAutoreverse 
  animations:^{

    myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);}  

  completion:^(BOOL finished){if (finished){

    myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);}}];

我知道我失去了一些东西,但不知道从哪里开始:(

I know that I'm missing something but don't know where to start :(

UPDATE1:我在执行嵌套的6动画后,在那里previous各一个下一个动画执行。对于我使用的块动画和表演完全块每一个动画。

UPDATE1: I'm performing nested 6 animations where each next animation performs after previous one. For that I'm using block animations and performing each next animation in complete block.

UPDATE2:我曾尝试与UIViewAnimationOptionRepeat选择,但还是有每个刻度动画完成后,一些闪光效果

UPDATE2: I have tried with UIViewAnimationOptionRepeat option but there's still some flash effect after each scale animation.

推荐答案

UIViewAnimationOptionAutoreverse 不做任何事不也使用 UIViewAnimationOptionRepeat 选项。书面将图像缩小到90%,然后弹回至100%,在完成块的动画。也许你可以按照这个动画与另一个,超过四分之一的第二个扩展恢复到100%。事情是这样的:

UIViewAnimationOptionAutoreverse does nothing without also using the UIViewAnimationOptionRepeat option. Your animation as written will shrink the image to 90%, then snap back to 100% in the completion block. Maybe you can follow this animation with another that scales back to 100% over a quarter second. Something like this:

    [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut 
                 animations:^{
                     myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);}  
                 completion:^(BOOL finished){if (finished){

    [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionCurveEaseInOut 
                     animations:^{
                         myImage.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.0, 1.0);}  
                     completion:NULL];}}];

这篇关于如何使用的UIView animateWithDuration比例适当的UIImageView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆