Basis
@ derives from UIView, so it is a view, or it can be attached to a view.
I. Creating
Copy Code code as follows:
Because the size of the Uiactivityindicatorview is fixed, you can set it directly. Center
uiactivityindicatorview* Activityindicatorview = [[Uiactivityindicatorview alloc]
Initwithframe:cgrectmake (250.0,20.0,30.0,30.0)];
Two. property settings style
Copy Code code as follows:
Activityindicatorview.activityindicatorviewstyle= Uiactivityindicatorviewstylegray;
The system offers you 3 different styles:
- Uiactivityindicatorviewstylewhitelarge Large White Indicator
- Uiactivityindicatorviewstylewhite Standard size White indicator
- Uiactivityindicatorviewstylegray Gray indicator, for white background
To set the Hideswhenstoped property to Yes if you want the indicator to be automatically hidden after it stops. The default is yes. The indicator will still appear when set to No stop.
Copy Code code as follows:
activityindicatorview.hideswhenstoped = NO;
Three. Show
You can attach it to any view, such as a table cell, or a view:
Copy Code code as follows:
[Self.view Addsubview:activityindicatorview];
Four. Start and stop (can be used with Nstimer, as a parameter userinfo to pass in)
Copy Code code as follows:
[Activityindicatorview startanimating];//Boot
[Activityindicatorview stopanimating];//Stop
@ Network Activity Indicator
When your application uses the network, you should put a network indicator on the iphone's status bar to warn users that they are using the network.
At this point you can use a uiapplication named Networkactivityindicatorvisible attribute.
You can enable or disable network indicators by setting this: uiapplication* app = [UIApplication sharedapplication];
app.networkactivityindicatorvisible = YES;
Gear Wait Animation instance
Uiactivityindicatorview provides a lightweight view that displays a standard rotational progress wheel, as long as it is added to the program, start and stop in the appropriate place. The start can be adsorbed in the current view, the stop will be removed ~
The effect of a simple answer:
The implementation method is as follows:
Copy Code code as follows:
Self.activityindicatorview=[[uiactivityindicatorview alloc]initwithframe:cgrectmake (0, 0, 100, 100)];
Self.activityindicatorview.center=self.view.center;
[Self.activityindicatorview Setactivityindicatorviewstyle:uiactivityindicatorviewstylegray];
[Self.activityindicatorview Setactivityindicatorviewstyle:uiactivityindicatorviewstylewhitelarge];
[Self.activityindicatorview Setbackgroundcolor:[uicolor Lightgraycolor]];
[Self.view AddSubview:self.activityIndicatorView];
[Self.activityindicatorview startanimating];
The code is very simple, set the frame this needless to say, about style setting, there are three kinds of white and gray, both sizes are 20*20, the big white picture is 37*37:
Copy Code code as follows:
typedef ns_enum (Nsinteger, Uiactivityindicatorviewstyle) {
Uiactivityindicatorviewstylewhitelarge,
Uiactivityindicatorviewstylewhite,
Uiactivityindicatorviewstylegray,
};
To turn off animations:
Copy Code code as follows:
Dispatch_after (Dispatch_time Dispatch_time_now, (int64_t) (5* nsec_per_sec)), Dispatch_get_global_queue (DISPATCH_ Queue_priority_default, 0), ^{
[Self.activityindicatorview stopanimating];
});