スキップしてメイン コンテンツに移動

keyframe animation

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 120.0f, 120.0f)];
    view.backgroundColor = [UIColor redColor]; // 初期表示は赤色
    [self.view addSubview:view];
    
    // 2秒間キーフレームアニメーションを実行する(逆再生&リピート)
    [UIView animateKeyframesWithDuration:2.0
                                   delay:0.0
                                 options:UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat
                              animations:^{
                                  // 0.8秒間(2.0 * 0.4)かけて背景を黄色に
                                  [UIView addKeyframeWithRelativeStartTime:0.0
                                                          relativeDuration:0.4
                                                                animations:^{
                                                                    view.backgroundColor = [UIColor yellowColor];
                                                                }];
                                  
                                  // 0.8秒間(2.0 * 0.4)後に1.2秒間(2.0 * 0.6)かけて背景を緑色に
                                  [UIView addKeyframeWithRelativeStartTime:0.4
                                                          relativeDuration:0.6
                                                                animations:^{
                                                                    view.backgroundColor = [UIColor greenColor];
                                                                }];

                              } completion:NULL];

コメント

このブログの人気の投稿

日本に来た 今三週間

四月六日に日本に来た、今三週間になった。 嬉しくなかった、悲しくなかった。 日本の携帯電話のカメラはとてもいいよ、私は今撮影が好きだ、いつも寮に帰る途中で花とか魚とか写真を撮る。これも生活の趣味だ。 滴は綺麗だ 桜が凋んで落ちる 天気がいいとき、自転車に乗って、食材を買った。 自分で料理をつくる、おいしそうでしょう。 昨日清水寺に行った、天気はとても熱いね。日に焼けすぎたので、腕は今赤い。 側に花があるので、赤い清水寺はもっと美しそうだ。 木の色は艶やかだ。