Inherit with UIView, call start and stop events directly;
@interface Activityindicatorview ()
{
Uiimageview *_imageview;
UILabel *_label;
}
@end
@implementation Activityindicatorview
-(ID) initWithFrame: (cgrect) frame
{
Self = [super Initwithframe:frame];
if (self)
{
Nsmutablearray *images = [nsmutablearray array];
For (int i = 1; I <= 8; i++)
{
nsstring *imagename = [nsstring stringWithFormat:@"activity_0%d. PNG", I];
NSString *path = [[NSBundle mainbundle] pathforauxiliaryexecutable: imageName];
UIImage *image = [UIImage imagewithcontentsoffile:p ath];
[Images addobject:image];
}
_imageview = [[Uiimageview alloc] init];
_imageview. bounds = CGRectMake (0, 0, + );
_imageview. Center = Cgpointmake(cgrectgetmidx(selfBounds), Cgrectgetmidy( Self . bounds));
_imageview. animationimages = images;
_imageview. Animationduration = 1. 0;
_imageview. Animationrepeatcount = 0;
[self addsubview:_imageview];
_label = [[UILabel alloc]initwithframe: CGRectMake(screen_width / 2 - (+ )];
_label. Text = @" Network load, please wait ...";
_label. Font = [Uifont systemfontofsize:];
_label. TextAlignment = Nstextalignmentcenter;
[_imageview addsubview: _label];
_label. alpha = 0. 0;
[_label release];
[_imageview release];
}
return self;
}
-(void) Start
{
_label. alpha = 1. 0;
[_imageview startanimating];
}
-(void) Stop
{
_label. alpha = 0. 0;
[_imageview stopanimating];
}