ios - 一个接一个地动画 3 个 View

标签 ios iphone xcode caanimation

我正在尝试一个接一个地为 3 个不同的 View 设置动画以显示同步。如何使用 CAAnimation 实现此目的。 尝试使用 Gcd 通过一个接一个地调用 3 个方法来做到这一点,我显示第一个圆圈并隐藏其他圆圈。但遇到了一些问题。

enter image description here

最佳答案

你可以在不使用动画的情况下做这样的事情。
为 exa 1,2 和 3 的三个 View 设置标签

 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;
}


 }

希望这会有所帮助:)

关于ios - 一个接一个地动画 3 个 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36690819/

相关文章:

iphone - iOS 移动配置 "Not Verified"

iphone - iTunes Connect 应用程序名称与 Bundle 在 info.plist 中的显示名称

jquery - 同时播放背景音乐和音效

ios - 如何减少我的 ipa 构建大小?

ios - 使用 CGContextAddArcToPoint() 绘制圆弧时,(x1,y1) 和 (x2,y2) 是什么意思?

ios - 由于空数组导致应用程序崩溃

ios - UIDocumentInteractionController - 显示 "Quick Look"选项

ios - iPhone View 移动动画

ios - 如何下载iOS私钥证书分发?

ios - 核心数据 : annotation: Failed to load optimized model at path with Xcode 9 GM