Iphone 如何使用UIView animateWithDuration正确缩放UIImageView?

Iphone 如何使用UIView animateWithDuration正确缩放UIImageView?,iphone,objective-c,animation,uiimageview,scaling,Iphone,Objective C,Animation,Uiimageview,Scaling,我正在缩放UIImageView,然后使用UIViewAnimateWithDuration和UIViewAnimationOptionAutoreverse选项还原它。问题是图像动画在动画结束时有点锯齿状(抽搐)。这是我的密码: [UIView animateWithDuration:0.25 delay:0 options:UIViewAnimationOptionAutoreverse animations:^{ myImage.transform = CGAffineTr

我正在缩放UIImageView,然后使用UIViewAnimateWithDuration和UIViewAnimationOptionAutoreverse选项还原它。问题是图像动画在动画结束时有点锯齿状(抽搐)。这是我的密码:

[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);}}];
我知道我错过了一些东西,但不知道从哪里开始:(

更新1:我正在执行嵌套的6个动画,其中每个下一个动画在上一个动画之后执行。为此,我使用块动画并在完整块中执行每个下一个动画


更新2:我尝试使用UIViewAnimationOptionRepeat选项,但每次缩放动画后仍会有一些闪光效果。

UIViewAnimationOptionAutoreverse
如果不使用
UIViewAnimationOptionRepeat
选项,则不会执行任何操作。编写的动画会将图像缩小到90%,然后在t中恢复到100%完成块。也许你可以用另一个在四分之一秒内缩放到100%的动画来跟随这个动画。类似这样:

    [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];}}];
.h文件declerd

NSInteger imgint;
.m文件,然后重试

-(void) 
{
    [NSTimer scheduledTimerWithTimeInterval:(0.85f)target:self selector:@selector(play_btn_animation) userInfo:nil repeats:YES];   
}

-(void)play_btn_animation
{
    if(imgint == 0)
    {
        [UIView animateWithDuration:0.8
                              delay:0.0
                            options: UIViewAnimationOptionCurveEaseIn
                         animations:^{
                             img.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.8, 0.8);
                         }
                         completion:^(BOOL finished) {
                             img = 1;
                         }];

    }
    else
    {
        [UIView animateWithDuration:0.8
                              delay:0.0
                            options: UIViewAnimationOptionCurveEaseOut
                         animations:^{
                             img.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1, 1);
                         }
                         completion:^(BOOL finished) {
                             imgint = 0;
                         }];
    }
}

你看,这6个自动翻转动画的实现覆盖了~3页线条清晰的代码。现在,每个动画有两个不同的动画会导致我有12个动画,代码非常大和混乱。我认为使用自动翻转可以节省一些空间,但如果它不起作用,那么唯一的解决办法就是这样做。