Breaking News
Home / iOS / iOS Snippets / How to add Activity Indicator to UIView in iOS?

How to add Activity Indicator to UIView in iOS?

Answer

// Create the instance

UIActivityIndicatorView  *indicator = [[[UIActivityIndicatorView alloc]initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];

// indicator.frame=CGRectMake(240, 160, 25, 25); // some location

indicator.frame = CGRectMake(round((self.view.frame.size.width – 25) / 2), round((self.view.frame.size.height – 25) / 2), 25, 25);

[self.view addSubview:indicator];

[indicator startAnimating]

…. Code to do a task like downloading image/page etc.

// remove it
[indicator removeFromSuperview];

[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger