动画无法在UIImageView上运行

时间:2015-12-18 20:12:01

标签: ios objective-c animation uiimageview uianimation

我添加了一个UIImageView作为子视图。我试图使用变换动画它。动画没有,但是图像视图是正确缩放的,它不是自动反转。我做错了吗?

UIImageView * iv_tap = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gesture_tap"]];
    iv_tap.center = point;
    iv_tap.tag = 779;
    iv_tap.hidden = true;
    [UIView animateWithDuration:2.0
                          delay:.05
                        options: UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat | UIViewAnimationOptionCurveLinear
                     animations:^{
                         iv_tap.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.8, 1.8);
                     }
                     completion:NULL];


    [self addSubview:iv_tap];

1 个答案:

答案 0 :(得分:1)

from app_name.views import get_url, get_token 添加到imageView后,您需要执行动画。如果你在view之前进行动画,那么图像视图不在视图中,并且你看不到任何动画。

addSubView

如果你是UIView的子类,那么你甚至可以把它放在drawRect方法中:

 UIImageView * iv_tap = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"gesture_tap"]];
[self.view addSubview:iv_tap];   //this could be self in your case
iv_tap.tag = 779; 

[UIView animateWithDuration:2.0 delay:0.05  options:UIViewAnimationOptionCurveEaseOut animations:^{

    iv_tap.center=self.view.center;
    iv_tap.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.8, 1.8);

    [self.view layoutIfNeeded];    //this could be self in your case

} completion:^(BOOL finished) {
        //do your stuff when animation is done
}];