1在.h或者.m中添加UIActivityIndicatorView的属性
@property(retain,nonatomic)UIActivityIndicatorView *indicator;
2.添加代码:
#pragma mark -- 风火轮
- (void)creatLoadingView
{
self.indicator = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height)];
[_indicator setBackgroundColor:[UIColor clearColor]];
//设置显示样式,见UIActivityIndicatorViewStyle的定义
_indicator.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
//设置显示位置
_indicator.center = self.view.center;
//将初始化好的indicator add到view中
[self.view addSubview:_indicator];
[self.view bringSubviewToFront:_indicator];
//开始显示Loading动画
[_indicator startAnimating];
}
3在sele.view子视图添加结束后再添加风火轮,不然会造成风火轮不显示
- (void)creatscrollView{
self.scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height * 19/25)];
self.scrollView.delegate = self;
self.scrollView.contentSize = CGSizeMake(self.scrollView.width *2, self.scrollView.height);
self.scrollView.contentOffset = CGPointMake(0, 0);
self.scrollView.delegate = self;
self.scrollView.pagingEnabled = YES;
[self.view addSubview:self.scrollView];
self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(self.scrollView.width, 0, self.scrollView.width, self.scrollView.height)];
self.webView.delegate = self;
[self.scrollView addSubview:self.webView];
[self creatLoadingView];
}