Ios 在NSArray中设置动画时更改UIImageView的位置
因此,我看到了大量的参考资料,它们回答了关于如何更改UIImageView位置的类似问题,可以这样做:Ios 在NSArray中设置动画时更改UIImageView的位置,ios,cocoa-touch,animation,uiimageview,Ios,Cocoa Touch,Animation,Uiimageview,因此,我看到了大量的参考资料,它们回答了关于如何更改UIImageView位置的类似问题,可以这样做: myUIImageView.center = CGPointMake(myImage_X, myImage_Y); myUIImageView.animationImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"img1.png"],
myUIImageView.center = CGPointMake(myImage_X, myImage_Y);
myUIImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"img1.png"],
[UIImage imageNamed:@"img2.png"],
[UIImage imageNamed:@"img3.png"],nil];
[myUIImageView setAnimationRepeatCount:0];
myUIImageView.animationDuration = 1.0;
[myUIImageView startAnimating];
但是,当我的UIImageView设置动画时,我无法实现这一点
我这样开始我的动画:
myUIImageView.center = CGPointMake(myImage_X, myImage_Y);
myUIImageView.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"img1.png"],
[UIImage imageNamed:@"img2.png"],
[UIImage imageNamed:@"img3.png"],nil];
[myUIImageView setAnimationRepeatCount:0];
myUIImageView.animationDuration = 1.0;
[myUIImageView startAnimating];
然后尝试用上面的代码行移动它。。。这没用。
在将其设置为属性并合成后,我尝试了以下方法:
[myUIImageView setFrame:CGRectMake( 10,
10,
myUIImageView.frame.size.width,
myUIImageView.frame.size.height
)];
但它不会移动图像:(
目前,我的图像正在现场进行动画制作。但我希望它首先改变位置(将坐标设置为屏幕顶部),然后使其沿Y方向下降。我在做什么傻事吗?myUIImageView=CGPointMake(myImage_X,myImage_Y);myUIImageView=0.1;您认为该怎么办?听起来像是自动布局问题。如果您的图像视图使用自动布局,您不应该设置任何帧来移动它,您应该修改约束。@NekakKinich抱歉我键入了错误。遗漏了。animationDuration。@rdelmar看起来您是对的。我禁用了大小类和自动布局yout,它工作得很好。谢谢你提到这一点。最好保持自动布局打开,然后像我说的那样移动视图。