[英]How to make my activity indicator view cover all screen?
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];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.