有时候,咱们但愿在整个页面提示 UIActivityIndicator ,通常的会在页面上面加一层 View ,其透明有底色,但那是不必定的,我能够只使用 UIActivityIndicator 来实现,只是对 一 中的代码修改一下,代码以下。markdown
- (IBAction)click_button:(id)sender { self.activity_indicator_view = [[UIActivityIndicatorView alloc] initWithFrame:self.view.bounds]; [self.activity_indicator_view setUserInteractionEnabled:YES]; [self.activity_indicator_view setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhiteLarge]; self.activity_indicator_view.backgroundColor = [UIColor grayColor]; self.activity_indicator_view.alpha = 0.5; [self.view addSubview:self.activity_indicator_view]; [self.activity_indicator_view startAnimating]; NSLog(@"aaaa"); }
咱们作的修改是如下几点:
* 初始化时指定 UIActivityIndicator 的框架为当前 View 的大小
* 为其是指背景色和透明度框架
效果以下图
spa