Ios 逐个设置3个视图的动画
我正在尝试一个接一个地设置3个不同视图的动画以显示同步。如何使用动画来实现这一点。 我试着用Gcd一个接一个地调用3个方法,在那里我显示了第一个圈,隐藏了其他圈。但是遇到了一些问题Ios 逐个设置3个视图的动画,ios,iphone,xcode,caanimation,Ios,Iphone,Xcode,Caanimation,我正在尝试一个接一个地设置3个不同视图的动画以显示同步。如何使用动画来实现这一点。 我试着用Gcd一个接一个地调用3个方法,在那里我显示了第一个圈,隐藏了其他圈。但是遇到了一些问题 您可以在不使用动画的情况下执行类似操作。 将标记设置为exa 1、2和3的三个视图 NSTimer *timerLabelTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimerLab
您可以在不使用动画的情况下执行类似操作。
将标记设置为exa 1、2和3的三个视图
NSTimer *timerLabelTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateTimerLabel) userInfo:nil repeats:YES];
int counter = 0;
-(void)updateTimerLabel{
if (counter == 0) {
UIView *tempView = [self.view viewWithTag:0];
tempView.backgroundColor = [UIColor whiteColor];
UIView *tempView1 = [self.view viewWithTag:1];
tempView.backgroundColor = [UIColor blackColor];
UIView *tempView2 = [self.view viewWithTag:2];
tempView.backgroundColor = [UIColor blackColor];
}
if (counter == 1) {
UIView *tempView = [self.view viewWithTag:0];
tempView.backgroundColor = [UIColor blackColor];
UIView *tempView1 = [self.view viewWithTag:1];
tempView.backgroundColor = [UIColor whiteColor];
UIView *tempView2 = [self.view viewWithTag:2];
tempView.backgroundColor = [UIColor blackColor];
}
if (counter == 2) {
UIView *tempView = [self.view viewWithTag:0];
tempView.backgroundColor = [UIColor blackColor];
UIView *tempView1 = [self.view viewWithTag:1];
tempView.backgroundColor = [UIColor blackColor];
UIView *tempView2 = [self.view viewWithTag:2];
tempView.backgroundColor = [UIColor whiteColor];
//removed counter = 0; from here
}
//Update
counter ++;
if (counter == 3) {
counter =0;
}
}
希望这会有所帮助:)我建议使用
UIImageView.animationImages
,它比动画更容易、更快、能耗更低。使用NSTimer会阻塞UI。还有其他方法吗?检查更新部分。这是反增量中的一个小错误。像这样试试,在我的演示中效果很好。:)