処理中を表すローディング画面(ぐるぐる)を表示する。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
@property UIView *loadingView; @property UIActivityIndicatorView *indicator; - (void)viewDidLoad { [super viewDidLoad]; //背景をグレーにする _loadingView = [[UIView alloc] initWithFrame:self.view.bounds]; _loadingView.backgroundColor = [UIColor blackColor]; _loadingView.alpha = 0.5f; _indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)]; _indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; _indicator.center = self.view.center; _indicator.hidesWhenStopped = YES; //ぐるぐる開始 [_loadingView addSubview:_indicator]; [self.view addSubview:_loadingView]; [_indicator startAnimating]; } //ぐるぐる終了時 [_indicator stopAnimating]; [_loadingView removeFromSuperview]; |