1 //2 //BowenView.h3 //ios_0302_ drop-down refresh4 //5 //Created by Ma C on 16/3/2.6 //copyright©2016 Blog Technology. All rights reserved.7 //8 9 #import<UIKit/UIKit.h>Ten One @interfaceBowenview:uiview A - //to load the loading interface into that interface -+ (void) Showbowenviewfromsuperview: (UIView *) Superview; the //which interface to remove the loading interface from -+ (void) Removebowenviewfromsuperview: (UIView *) Superview; - //to load the loading interface to that interface (specific location) -+ (void) Showbowenviewfromsuperview: (UIView *) Superview OffSetY: (cgfloat) OffSetY; + - @end + A at - - // - //bowenview.m - //ios_0302_ drop-down refresh - // in //Created by Ma C on 16/3/2. - //copyright©2016 Blog Technology. All rights reserved. to // + - #import "BowenView.h" the * @interfaceBowenview () $ Panax Notoginseng //Dynamic Graphs -@property (nonatomic, strong) Uiimageview *Loadingimgview; the //hint Text +@property (nonatomic, strong) UILabel *lbl; A the @end + - $ $ @implementationBowenview - - the-(instancetype) init - {WuyiSelf =[Super init]; the if(self) { - [self addSubview:self.loadingImgView]; Wu [self addSubview:self.lbl]; - } About returnSelf ; $ } - --(Uiimageview *) Loadingimgview - { A if(!_loadingimgview) { +_loadingimgview =[[Uiimageview alloc] init]; the_loadingimgview.frame = CGRectMake (0,0, the, the); -_loadingimgview.backgroundcolor =[Uicolor Clearcolor]; $ //Dynamic Graph Properties the_loadingimgview.animationimages =[self getimagearray]; the_loadingimgview.animationduration =2.0; the_loadingimgview.animationrepeatcount =0; the } - return_loadingimgview; in } the the-(UILabel *) LbL About { the if(!_lbl) { the_LBL =[[UILabel alloc] init]; the_lbl.frame = CGRectMake (0, the, the, -); +_lbl.text =@"Loading ..."; -_lbl.font = [Uifont systemfontofsize: -]; the_lbl.textcolor =[Uicolor Darkgraycolor];Bayi_lbl.textalignment =Nstextalignmentcenter; the } the return_lbl; - } - //get an array of pictures the-(Nsarray *) Getimagearray the { theNsmutablearray *imgarray =[Nsmutablearray array]; theNsmutablearray *imgnamearr =[Nsmutablearray array]; - the for(intI=1; i< -; i++) { the theNSString *imgname = [NSString stringWithFormat:@"loading_animate_%02d", I];94 [Imgarray addobject:imgname]; the } the the for(inti =0; I < the; i + +) {98UIImage *image =[UIImage Imagenamed:[imgarray objectatindex:i]; About [Imgnamearr addobject:image]; - }101 returnImgnamearr;102 103 104 } the 106 //to load the loading interface into that interface107+ (void) Showbowenviewfromsuperview: (UIView *) Superview108 {109[Self Showbowenviewfromsuperview:superview OffSetY:0]; the }111 //which interface to remove the loading interface from the+ (void) Removebowenviewfromsuperview: (UIView *) Superview113 { the //Find in "All Child view arrays" in parent view the for(UIView *itemviewinchsuperview.subviews) { the if([Itemview Iskindofclass:[bowenviewclass]]) {117 [Itemview Removefromsuperview];118 }119 } - }121 //to load the loading interface to that interface (specific location)122+ (void) Showbowenviewfromsuperview: (UIView *) Superview OffSetY: (cgfloat) OffSetY123 {124Bowenview *loadingview =[[Bowenview alloc] init]; theLoadingview.frame = CGRectMake ([UIScreen mainscreen].bounds.size.width/2- +, $+ OffSetY, -, the);126 127 //determine if a bowenview already exists on the Superview, if it already exists, delete it before loading the new view - [self removebowenviewfromsuperview:superview];129 [Superview Addsubview:loadingview]; the 131 //let the dynamic graph move. the [Loadingview.loadingimgview startanimating];133 134 135 }136 137 @end
ios-loading a dynamic diagram (GIF)