开发者

iPhone activity indicator

开发者 https://www.devze.com 2023-03-01 20:07 出处:网络
How to load UIActivityIndicatorView in a login page? just like facebook iPho开发者_运维技巧ne App.your question is not clear. but this is the way to add activity indicator.

How to load UIActivityIndicatorView in a login page? just like facebook iPho开发者_运维技巧ne App.


your question is not clear. but this is the way to add activity indicator.

UIActivityIndicatorView *activity = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(225, 115, 30, 30)];
[activity setBackgroundColor:[UIColor clearColor]];
[activity setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[self.view addSubview:activity];
[activity release];

to start animating the activity

[activity startAnimating];

to stop animating the activity

[activity stopAnimating];


activityIndicator = [[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    activityIndicator.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
    activityIndicator.center = self.view.center;
    [self.view addSubview: activityIndicator];

Use [activityIndicator startAnimating]; when you want to animate


initialize like this..

UIActivityIndicatorView *activityView = [[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge] autorelease];
activityView.center = CGPointMake(240,160);
activityView.hidden = true;
[self.view addSubview: activityView];

when you want to animate

   activityView.hidden = FALSE;
   [activityView startAnimating] ;

when you want to stop

   [activityView stopAnimating];
   activityView.hidden = TRUE;

EDIT : After seeing the comment

Nothing peculiar about Facebook activity indicator.They just clearing there view along with showing when activity indicator starts animation..

You just create a view, say ActivityView, which covers the screen(or whatever section you want to make white), put a white background to the view, and add the activity indicator to the view..First hide this view, and when you want to show activity indicator unhide the view and start activity indicator animation..Write two member functions in activity indicator to start and stop animation, so that you can control the animation from anywhere..


CGRect frame = CGRectMake(self.view.frame.size.width/2-15, self.view.frame.size.height/2-15, 37, 37);
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithFrame:frame];
    [indicator startAnimating];
    indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    [indicator sizeToFit];
    indicator.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin |
                                    UIViewAutoresizingFlexibleRightMargin |
                                    UIViewAutoresizingFlexibleTopMargin |
                                    UIViewAutoresizingFlexibleBottomMargin);

    indicator.tag = 1;
    [self.view addSubview:indicator];
    [indicator release];
0

精彩评论

暂无评论...
验证码 换一张
取 消