The activity Indicator (Uiactivityindicatorview) informs the user that an operation is in progress. The progress indicator (Uiprogressview) also has the same function, and also tells the user how far away the operation ends.
Both of these indicators are derived from UIView, so they are views or can be attached to a view.
First, Uiactivityindicatorview activity indicator
1. Create
- uiactivityindicatorview* Activityindicatorview = [[Uiactivityindicatorview alloc]
- Initwithframe:cgrectmake (250.0,20.0,30.0,30.0)];
2. Property settings
Style:
- 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
- Auto Hide
If you want the indicator to be automatically hidden after it stops, set the Hideswhenstoped property to Yes. The default is yes. The indicator will still appear after set to No stop.
- activityindicatorview.hideswhenstoped = NO;
3. Display
You can attach it to any view, such as a table cell, or a view:
- [Self.view Addsubview:activityindicatorview];
4. Start and stop
- [Activityindicatorview startanimating]; //Start
- [Activityindicatorview stopanimating]; //Stop
Second, Uiprogressview progress indicator
Uiprogressview is similar to Uiactivityindicatorview, except that it provides an interface that allows you to display something like a progress bar, so that the user can know how much of the current operation is done.
1. Create
- uiprogressview* Progressview = [[Uiprogressview alloc]
- Initwithframe:cgrectmake (150.0,20.0,130.0,30.0)];
2. Property settings
Style:
- Progressview. Uiprogressviewstyle= Uiprogressviewstyledefault;
The system offers you 2 different styles:
- Uiprogressviewstyledefault Standard progress bar
- Uiprogressviewstyledefault Dark gray progress bar, for use in toolbars
3. Display
- [Self.toolbar Addsubview:progressview];
4. Progress
- When it appears that your program can update its progress, the property Progre is a floating-point number between 0.0 to 1.0 :
- Progressview.progress = 0. 5;
Third, the network activity indicator
- When your application uses the network, a network indicator should be placed on the iphone's status bar to warn users that they are using the network. At this point you can use a property named Networkactivityindicatorvisible for UIApplication. By setting this, you can enable or disable the network indicator: uiapplication* app = [UIApplication sharedapplication];
- pp.networkactivityindicatorvisible = YES;
Iv. expansion
Do you think you've learned something new? Do. But I have a better thing. Recommended: Mbprogresshud Https://github.com/jdg/MBProgressHUD A more NB third-party progress indicator, you can follow the example it provides to use it, very powerful. But one thing I'd like to remind you is that it's asynchronous, so it doesn't block your current program, and if you want to block your program, make a little bit of change in the logic control. Transferred from: http://blog.csdn.net/iukey/article/details/7308311
Uiactivityindicatorview, Uiprogressview activity and progress indicator-ios development