//
懒加载 第一种创建方式:初始化控件
-( UIActivityIndicatorView *)activity{
if (! _activity ) {
_activity = [[ UIActivityIndicatorView alloc ] initWithFrame : CGRectMake ( 0 , 0 , 44 , 44 )];
// 样式
_activity . activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge ;
// 设置位置
_activity . center = self . center ;
// 添加到控制器中
[ self addSubview : _activity ];
}
return _activity ;
-( UIActivityIndicatorView *)activity{
if (! _activity ) {
_activity = [[ UIActivityIndicatorView alloc ] initWithFrame : CGRectMake ( 0 , 0 , 44 , 44 )];
// 样式
_activity . activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge ;
// 设置位置
_activity . center = self . center ;
// 添加到控制器中
[ self addSubview : _activity ];
}
return _activity ;
}
//第一种创建方式:
数据没加载好之前转圈圈
[ self.activity startAnimating];
//
停止数据加载好后调用
[
self
.
activityView
stopAnimating
];
//第二种创建方式 :数据加载好之前 显示状态栏的圈圈
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
// 数据加载好后隐藏状态栏圈圈
[
UIApplication
sharedApplication
].
networkActivityIndicatorVisible
=
NO
;