iOS-UIImageView的帧动画

UIImageView的帧动画
@property(nonatomic,copy) NSArray *animationImages; // 设置需要播放的图片(到时会按照数组顺序播放)
@property(nonatomic) NSTimeInterval animationDuration; // 动画的持续时间
@property(nonatomic) NSInteger animationRepeatCount;  // 动画的执行次数(默认情况下是无限重复执行)
- (void)startAnimating; // 开始动画
- (void)stopAnimating;  // 停止动画
- (BOOL)isAnimating; // 是否正在执行动画

格式符补充
%03d : 每个整数占据3个位置,多出的位置用0填充
比如:
* [NSString stringWithFormat:@"%03d", 0];  返回的是@"000"
* [NSString stringWithFormat:@"%03d", 7];  返回的是@"007"
* [NSString stringWithFormat:@"%03d", 15];  返回的是@"015"
* [NSString stringWithFormat:@"%03d", 134];  返回的是@"134"

加载图片的两种方式
1.有缓存
UIImage *image = [UIImage imageNamed:@"a.png"]

2.无缓存
// 全路径
NSString *path = [[NSBundle mainBundle] pathForResource:@"a.png" ofType:nil];
// path是a.png的全路径
UIImage *image = [[UIImage alloc] initWithContentsOfFile:path]


子控件的操作
1.添加子控件 : addSubview:
2.从父控件中移除 : removeFromSuperview

动画
1.头尾式
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
// 需要执行动画的代码....
[UIView commitAnimations];

2.block式
[UIView animateWithDuration:1.0 animations:^{
    // 需要执行动画的代码....
} completion:^(BOOL finished) { // 动画执行完毕后会自动调用这个block(这个代码段)
    
}];
原文地址:https://www.cnblogs.com/DarbyCJ/p/3649357.html