代码改变世界

UIImageView实现图片幻灯片

2012-03-31 10:56  java环境变量  阅读(178)  评论(0编辑  收藏  举报
NSArray *myImages = [NSArray arrayWithObjects:
    [UIImage imageNamed:@"Image1.png"],
    [UIImage imageNamed:@"Image2.png"],
    [UIImage imageNamed:@"Image3.png"],
    [UIImage imageNamed:@"mage4.gif"],
    nil];

UIImageView *myAnimatedView = [UIImageView alloc];
[myAnimatedView initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImages;
myAnimatedView.animationDuration = 0.35; // seconds
myAnimatedView.animationRepeatCount = 0; // 0 代表一直循环。
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[myAnimatedView release];