IOS: Wheel Activity Refresh View Control Uiactivityindicatorview detailed use

Source: Internet
Author: User

Dynamic wheel View Control: Uiactivityindicatorview

Description: It is a view control similar to a wheel rotation that can be used as a refresh data when the loading process is used, inheriting from UIView. Type:

typedef ns_enum (Nsinteger, Uiactivityindicatorviewstyle) {

Uiactivityindicatorviewstylewhitelarge, //Large white type

Uiactivityindicatorviewstylewhite, //white type

Uiactivityindicatorviewstylegray, //grey type

};

Property:

@property (nonatomic) Uiactivityindicatorviewstyle Activityindicatorviewstyle; //Type

@property (nonatomic) BOOL hideswhenstopped; //Whether to hide when stopped

@property (ReadWrite, nonatomic, retain) Uicolor *color; //Color

Method:

-(Instancetype) Initwithactivityindicatorstyle: (uiactivityindicatorviewstyle) style; //Initialize method for instance creation

-(void) startanimating; //Start animation

-(void) stopanimating; //Stop animation

-(BOOL) isanimating; //Are you animating

@end

examples are as follows: In method -(void) viewdidload {[Super Viewdidload]; ...} Add the following code

//Create an instance of the active view Control

1     Uiactivityindicatorview *activityview = [[Uiactivityindicatorview alloc]initwithactivityindicatorstyle: Uiactivityindicatorviewstylewhitelarge];

Set the location of the instance

1     Activityview.center = Cgpointmake (;

Set controller view background color

1     [Self.view Setbackgroundcolor:[uicolor Redcolor];

//Add the control to the view

1     [Self.view Addsubview:activityview];

Start animation

1     [ActivityView startanimating];

Sets whether the animation is hidden when stopped

1     activityview.hideswhenstopped = YES;

Use timer to stop animation at 3 seconds

1     [Nstimer scheduledtimerwithtimeinterval:3 target:self selector: @selector (test:) UserInfo: ActivityView Repeats:no];

Start the application's network activity refresh animation

1     UIApplication *app = [uiapplication sharedapplication]; 2     [App Setnetworkactivityindicatorvisible:yes];

#pragma mark-test Timer Events

-(void) Test: (nstimer*) sender{    // Remove the control instance    Uiactivityindicatorview * ActivityView = [sender userInfo];         // Stop Animation     [ActivityView stopanimating];         // Stop the application's network activity refresh animation    UIApplication *app = [uiapplication sharedapplication];    [App Setnetworkactivityindicatorvisible:no];}

Demo Result:

Both of the steam wheels are animated: next to the network, a two-wheel-steamer in the view stops the animation at the timer's point in time:

IOS: Wheel Activity Refresh View Control Uiactivityindicatorview detailed use

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.