Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/109.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在UIView动画中使用数组值_Ios_Objective C_Uiview_Uiviewanimation - Fatal编程技术网

Ios 如何在UIView动画中使用数组值

Ios 如何在UIView动画中使用数组值,ios,objective-c,uiview,uiviewanimation,Ios,Objective C,Uiview,Uiviewanimation,在UIViewAnimation中,到目前为止,我使用单个图像从一个地方到另一个地方制作动画,如下所示: CGRect frame = button.frame; CGRect frame1 = button1.frame; frame.origin.x = frame1.origin.x; frame.origin.y = frame1.origin.y; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDur

UIViewAnimation
中,到目前为止,我使用单个图像从一个地方到另一个地方制作动画,如下所示:

CGRect frame = button.frame;
CGRect frame1 = button1.frame;
frame.origin.x = frame1.origin.x; 
frame.origin.y = frame1.origin.y; 

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDuration: 3.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView animateWithDuration:3.0 animations:^{

    [button setTransform:CGAffineTransformIdentity];

} completion:^(BOOL finished) {


}];
button.frame = frame;
[UIView commitAnimations];
在这里,我在一个数组中有九个图像:

redAppleArray = @[redApple1,redApple2,redApple3,redApple4,redApple5,redApple6,redApple7,redApple8,redApple9,redApple10];
我有文本显示随机数


我的问题是如何获取上述文本值并使用
UIViewAnimation
设置图像动画?i、 例如,如果
text=3
3 redApple
要设置动画。

要从标签中获取值,请执行以下操作:

int i = [[myLabel text] intValue];
然后使用它获取数组中的元素:

id *redApple = [redAppleArray objectAtIndex:i];

试着做些轻快的事情:

-(void)yourMethodToAnimateWithText:(NSString*)numberAsAText {
int = [numberAsAText intValue];
CGRect frame = button.frame;
CGRect frame1 = button1.frame;
frame.origin.x = frame1.origin.x; 
frame.origin.y = frame1.origin.y; 

// If you want to add some option use [UIView animateWithDuration:delay:option:animation:completion:]

[UIView animateWithDuration:3.0 animations:^{
    //[button setTransform:CGAffineTransformIdentity];
    button.frame = frame;
    //Animate your images, text, etc.
    } completion:^(BOOL finished) {
    }];
}

希望这就是你想要的。

文本在哪里?只是转换字符串->数字->数组索引?为什么要同时使用两种不同形式的动画?如何为UIView动画赋予数组值。因为我想一个接一个地制作红苹果的动画