首页 > iOS Keyframe animation 怎么对计数响应

iOS Keyframe animation 怎么对计数响应


UIView.animateKeyframesWithDuration(5, delay: 0, options: [UIViewKeyframeAnimationOptions.Repeat], animations: {
        UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 0.3, animations: {
            self.imageView!.center.x = self.view.bounds.width / 2
        })
        }, completion: nil)

}

比如上面这段代码 ,重复执行动画,每次执行完之后都比如说执行print("hello")
要怎么操作
求大神解答


好像不可以也试一下其他方法吧,要不用延时来调吧
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

    //            // 1秒后异步执行

});


动画闭包内的内容会在每次执行的时候触发


UIView.animateKeyframesWithDuration(5, delay: 0, options: [UIViewKeyframeAnimationOptions.Repeat], animations: {
        //执行这个关键帧动画时打印hello
        print("hello")
        UIView.addKeyframeWithRelativeStartTime(0, relativeDuration: 0.3, animations: {
            self.imageView!.center.x = self.view.bounds.width / 2
            //执行这一帧的时打印hello
            print("hello")
        })
        }, completion: nil)

}
【热门文章】
【热门文章】