首页 > 移动平台 > 详细

iOS-UIImageView的帧动画

时间:2014-04-06 23:39:44      阅读:732      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
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(这个代码段)
    
}];
bubuko.com,布布扣

 

iOS-UIImageView的帧动画,布布扣,bubuko.com

iOS-UIImageView的帧动画

原文:http://www.cnblogs.com/DarbyCJ/p/3649357.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!