标签:
继承关系
UIImageView --> UIView
一. 什么是UIImageView
二. UIImageView的常见属性
1. 创建UIImageView
UIImageView *image = [[UIImageView alloc] init];
2. 设置尺寸
image.frame = CGRectMake(0, 0, goodsW, goodsW);
3. 设置图片
image.image = [UIImage imageNamed:icon];
4. 加载动画图片
@property(nonatomic,copy) NSArray *animationImages;
5. 动画图片的持续时间
@property(nonatomic) NSTimeInterval animationDuration;
6. 动画的播放次数(默认是0,代表无限播放)
@property(nonatomic) NSInteger animationRepeatCount;
- (void)startAnimating; // 开始动画
- (void)stopAnimating; // 停止动画
- (BOOL)isAnimating; // 是否正在执行动画
三. UIImageView加载动画
1. 首尾方式
// 1.定义一个动画[UIView beginAnimations:nil context:nil];// 2.设置动画持续时间[UIView setAnimationDuration:2.0];// 3.取出image的frameCGRect tmepF = self.image.frame;// 取出image的boundsCGRect tmepB = self.image.bounds;// 4.根据按钮的tag判断方向switch (btn.tag) {case 10: // 上tmepF.origin.y -= f;break;case 20: // 下tmepF.origin.y += f;break;
}// 将tmep赋值给按钮self.image.frame = tmepF;self.image.bounds = tmepB;// 提交动画[UIView commitAnimations];
// 6.将图片数组加入到动画中self.iconImage.animationImages = images;// 7.设置动画次数self.iconImage.animationRepeatCount = 1;// 8.设置动画持续时间self.iconImage.animationDuration = count * 0.08;// 9.开始动画[self.iconImage startAnimating];
3. block 动画
// 慢慢出现(出现动画持续1秒)[UIView animateWithDuration:1.0 animations:^{self.hudLabel.alpha = 1.0;} completion:^(BOOL finished) {// 1.5秒后,再慢慢消失(消失动画持续1秒)[UIView animateWithDuration:1.0 delay:1.5 options:kNilOptions animations:^{self.hudLabel.alpha = 0.0;} completion:nil];}];
标签:
原文地址:http://www.cnblogs.com/Xfsrn/p/4842416.html