跳转网页的过程中的加载图

  1. 在viewDidLoad中,创建loadingView,并添加到self.view上面

2.在结束加载的时候,将loadingView移除

[self initloading];
[self.view addSubview:self.loading];
- (void)initloading
{
    UIView *loadingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, DEAppWidth, DEAppHeight)];
    loadingView.backgroundColor = DEColor(245, 245, 245);

    UIImageView *logo = [[UIImageView alloc] initWithFrame:CGRectMake(DEAppWidth / 2 - 50, 200, 100, 100)];
    [logo setImage:[UIImage imageNamed:@"加载"]];
    [loadingView addSubview:logo];
    
    CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"opacity"];
    animation.fromValue = [NSNumber numberWithFloat:1.0f];
    animation.toValue = [NSNumber numberWithFloat:0.0f];
    animation.autoreverses = YES;    //回退动画(动画可逆,即循环)
    animation.duration = 0.5f;
    animation.repeatCount = MAXFLOAT;
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;//removedOnCompletion,fillMode配合使用保持动画完成效果
    animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
    [logo.layer addAnimation:animation forKey:@"aAlpha"];
    
    UILabel *tips = [[UILabel alloc] initWithFrame:CGRectMake(0, 320, DEAppWidth, 20)];
    tips.textColor = DENavBarColorBlue;
    tips.text = @"加载中...";
    tips.textAlignment =  NSTextAlignmentCenter;
    tips.font = [UIFont systemFontOfSize:20.0];
    [loadingView addSubview:tips];
    
    self.loading = loadingView;
    
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.loading removeFromSuperview];
    });
}

跳转网页的过程中的加载图_第1张图片
图片.png

你可能感兴趣的:(跳转网页的过程中的加载图)