Raj
Raj

Reputation: 1213

Set the frame of UIActivityIndicatorView

I have problem with Activity Indicator… if i am set the frame of Indicator is show the black background behind UIActivity indicator. and if i not set frame its look well but not in proper position. now how can i set Indicator to proper position?

Upvotes: 1

Views: 4128

Answers (2)

JiteshW
JiteshW

Reputation: 2205

Addind to @Raj answer. Rather than calculating 'w' and pasing them in CGPointMake, you can use bound property.

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
indicator.center = CGPointMake(CGRectGetMidX(yourView.bounds), CGRectGetMidY(yourView.bounds));
[yourView addSubview:indicator];

Upvotes: 1

Raj
Raj

Reputation: 1213

Its work well with this code..

activityIndicator=[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

[activityIndicator setCenter:CGPointMake(w/2-5,w/2-5)];

[activityIndicator setContentMode:UIViewContentModeCenter];

[activityIndicator startAnimating];
[self addSubview:activityIndicator];

Upvotes: 10

Related Questions