So when a user clicks on a button in my app, I would like to create a new view with an activity indicator and cover the whole screen with it until the button action finishes.
However, my activity indicator view is covering only inside of a table view, it looks like this:
How to make it cover whole screen? Including the navigation controller and table view toolbar.
Here is my code I use to create the view:
self.overlayView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.overlayView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.5];
self.activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
self.activityIndicator.center = self.overlayView.center;
[self.overlayView addSubview:self.activityIndicator];
[self.activityIndicator startAnimating];
[self.tableView addSubview:self.overlayView];
Change
[self.tableView addSubview:self.overlayView];
To
[self.navigationController.view addSubview:self.overlayView];
Set the overlay's rect accordingly.
做这个:
[[UIApplication sharedApplication].keyWindow addSubview:self.overlayView];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.