Skip to content

Instantly share code, notes, and snippets.

@scottsappen
Last active December 19, 2015 19:48
Show Gist options
  • Save scottsappen/6008368 to your computer and use it in GitHub Desktop.
Save scottsappen/6008368 to your computer and use it in GitHub Desktop.
Large white activity animator inside UIView with greyed out background displayed in middle of screen. Could be included in an asynchronous NSURLConnection web call, for instance, and on the processing of the response, it could remove itself from its superview.
UIView *activityContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
activityContainer.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.25];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake((self.view.frame.size.width/2) - 40, (self.view.frame.size.height/2) - 40, 80, 80)];
indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
indicator.backgroundColor = [UIColor blackColor];
[indicator layer].cornerRadius = 8.0;
[indicator layer].masksToBounds = YES;
[indicator startAnimating];
[activityContainer addSubview:indicator];
[self.view addSubview:activityContainer];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment