3.关于图像的实例化

imageNamed: 系统推荐使用的,但是图像实例化之后的释放由系统负责;如果要自己释放图片,不能使用imageNamed:方法,而需要使用imageWithContentOfFile
提示1:如果是放在Images.xcassets的图片,不能使用imageWithContentOfFile;images.xcassets中不要存放大的,不常用的图片;
提示2:
- (void)tomAnimationWithName:(NSString *)name count:(NSInteger)count
{
// 如果正在动画,直接退出
if([self.tom isAnimating]) return;
// 动画图片的数组
NSmutableArray *arrM = [NSMutableArray array];
// 添加动画播放的图片
for(Int i = 0; i < count; i++)
{
NSString *imageName = [NSString stringWithFormat:@”%@_02d”, name, i];
NSString *path = [[NSBundle mainBundle] pathResource: imageName ofTye: nil];
UIImage *image = [UIImage imageWithContentOfFile: path];
[arrM addobject: image];
}
// 设置动画数组
self.tom.animationImages = arrM;
// 重复次数
self.tom.animationRepeatcount = 1;
// 动画时间
self.tom.animationDuration = self.tom.animationImages.count * 0.075;
// 开始动画
[self.tom startAnimating];
// 在动画执行过程后,记得要释放当前数组的内存
[self.tom performSelector:@Selsctor(setAnimationImages:) withObject:nil afterDelay:self.tom.animationDuration];
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值