文字や画像等を点滅させたいときのメモ。
INDEX
点滅アニメーションのサンプルソース
QuartzCoreフレームワークを使用する。
- ViewController.h
-
[code]
#import <QuartzCore/QuartzCore.h>
[/code] - ViewController.m
-
[code]
– (void)blinkImage:(UIImageView *)target {
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@”opacity”];
animation.duration = 0.1f;
animation.autoreverses = YES;
//animation.repeatCount =
animation.repeatCount = 3; //infinite loop -> HUGE_VAL
animation.fromValue = [NSNumber numberWithFloat:1.0f]; //MAX opacity
animation.toValue = [NSNumber numberWithFloat:0.0f]; //MIN opacity
[target.layer addAnimation:animation forKey:@”blink”];
}
[/code]
まとめ
ブロックを併用すれば、より高度なアニメーションが実現出来ますね。