定制加载指示器(旋转器)

时间:2011-03-28 16:55:50

标签: iphone cocoa-touch uiview

我想替换使用我的自定义图像从服务器加载数据时出现的默认微调器。我有16张图片。

知道如何用自定义加载指示器替换它吗?

1 个答案:

答案 0 :(得分:7)

这可以使用UIImageView完成(如果您愿意,可以创建自定义UIView子类)。基本代码是这样的:

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.frame];

animatedImageView.animationImages = [NSArray arrayWithObjects:    
                            [UIImage imageNamed:@"spinner-01.png"],
                            [UIImage imageNamed:@"spinner-02.png"],
                            [UIImage imageNamed:@"spinner-03.png"],
                            [UIImage imageNamed:@"spinner-04.png"], 
                            nil];

animatedImageView.animationDuration = 1.0;
animatedImageView.animationRepeatCount = 0;

[animatedImageView startAnimating];