UIImageView动画显示

来源:互联网 发布:python项目实战 知乎 编辑:程序博客网 时间:2024/06/16 08:52

 

NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];

NSArray *myImages = [NSArray arrayWithObjects: [UIImage imageNamed:@"myImage1.png"], [UIImage imageNamed:@"myImage2.png"], [UIImage imageNamed:@"myImage3.png"],  [UIImage imageNamed:@"myImage4.gif"], nil];

UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:[self bounds]];

myAnimatedView.animationImages = myImages; //animationImages属性返回一个存放动画图片的数组

myAnimatedView.animationDuration = 0.25; //浏览整个图片一次所用的时间

myAnimatedView.animationRepeatCount = 0; // 0 = loops forever 动画重复次数

[myAnimatedView startAnimating];

[self addSubview:myAnimatedView];

[myAnimatedView release];

[pool drain];

 

原创粉丝点击