UIActivityIndicatorView活动指示器
活动指示器:UIActivityIndicatorView
用途:指示用户,程序正在运行之中
派生:UIView,可以被当成视图加载
创建:UIActivityIndicatorView *view=[[UIActivitiIndicatorView alloc]initWithFrame:CGRectMake(0,0,32,32)];
属性设置:
风格
activityIndicatorViewStyle:
UIActivityIndicatorViewStyleWhite 白色标准
UIActivityIndicatorViewStyleWhiteLarge 白色加大
UIActivitIndicatorViewStyleGrey 灰色指示器,用于白色背景
中点设置
方法 setCenter = self.view.center;将指示器仿制的视图的中间
隐藏
当指示器停止后自动隐藏:activityIndicator.hideWhenStoped=YES;默认为YES
不隐藏则设置为NO
启动:方法 startAnimating
停止:方法 stopAnimating
示例代码
1 #import "ViewController.h" 2 3 @interface ViewController () 4 5 @end 6 7 @implementation ViewController 8 @synthesize indicatorView; 9 - (void)viewDidLoad 10 { 11 [super viewDidLoad]; 12 // Do any additional setup after loading the view, typically from a nib. 13 indicatorView =[[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0.0, 0.0, 32, 32)]; 14 indicatorView.activityIndicatorViewStyle=UIActivityIndicatorViewStyleWhiteLarge; 15 [indicatorView setCenter:self.view.center]; 16 [self.view addSubview:indicatorView]; 17 [indicatorView startAnimating]; 18 } 19 20 - (void)didReceiveMemoryWarning 21 { 22 [super didReceiveMemoryWarning]; 23 // Dispose of any resources that can be recreated. 24 } 25 26 @end