UIActivityIndicatorView
2017-11-22 本文已影响108人
翻这个墙
UIActivityIndicatorView
- 继承自UIView
- 俗称为“菊花”
UIActivityIndicatorView样式
-
UIActivityIndicatorViewStyleGray
UIActivityIndicatorViewStyleGray.png
- UIActivityIndicatorViewStyleWhite
-
背景是白色不可见
UIActivityIndicatorViewStyleWhite.png
-
- UIActivityIndicatorViewStyleWhiteLarge
-
背景是白色不可见
UIActivityIndicatorViewStyleWhiteLarge.png
-
UIActivityIndicatorView自定义指示器效果示例
- (void)diyHUD
{
// 创建遮盖
UIView *cover = [[UIView alloc] init];
cover.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
cover.bounds = CGRectMake(0, 0, 200, 150);
cover.layer.cornerRadius = 10;
cover.center = CGPointMake(self.view.frame.size.width * 0.5, self.view.frame.size.height * 0.5);
[self.view addSubview:cover];
// 往遮盖中添加菊花
UIActivityIndicatorView *loadingView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[loadingView startAnimating];
loadingView.center = CGPointMake(cover.frame.size.width * 0.5, cover.frame.size.height * 0.5);
[cover addSubview:loadingView];
// 往遮盖中添加提醒文字
UILabel *label = [[UILabel alloc] init];
label.text = @"正在拼命加载中...";
label.textAlignment = NSTextAlignmentCenter;
CGFloat labelH = 70;
label.textColor = [UIColor whiteColor];
label.frame = CGRectMake(0, cover.frame.size.height - labelH, cover.frame.size.width, labelH);
[cover addSubview:label];
}