zoukankan      html  css  js  c++  java
  • LoadingView 自定义加载图片

    #import <UIKit/UIKit.h>

    @interface LoadingView : UIView

    @property (nonatomic,strong) NSMutableArray *giftImageArray;

    +(id)showLoadingView;

    +(void)hidenLoadingView:(LoadingView *)loadingView;

     @end

    #import "LoadingView.h"

    - (instancetype)init

    {

        self = [super init];

        if (self) {

            self.frame = CGRectMake( 0, 0, ScreenWidth, ScreenHeight);

            

            UIView *backView = [[UIView alloc]initWithFrame:CGRectMake( 0, 0, ScreenWidth, ScreenHeight)];

            backView.backgroundColor = [UIColor blackColor];

            backView.alpha = 0.7;

            [self addSubview:backView];

        }

        return self;

    }

    +(id)showLoadingView{

        LoadingView *loadingView = [[LoadingView alloc]init];

        

        NSMutableArray *array = [NSMutableArray array];

        for (int i = 0; i < 7; i++) {

            UIImage *image = [UIImage imageNamed:[NSString stringWithFormat: @"loading_da%d",i+1]];

            [array addObject:image];

        }

        UIImageView *loading = [[UIImageView alloc]initWithFrame:CGRectMake( ScreenWidth/2-Width(77), ScreenHeight/2 - Width(77), Width(154), Width(154))];

        [loadingView addSubview:loading];

        [UIView animateWithDuration:1 animations:^{

            

        } completion:^(BOOL finished) {

            loadingView.giftImageArray = array;

            loading.animationDuration = 0.7;

            loading.animationImages = loadingView.giftImageArray;

            loading.animationRepeatCount = 0;

            loading.image = [loadingView.giftImageArray firstObject];

            

            [loading startAnimating];

        }];

        [loadingView show];

        

        return loadingView;

    }

    +(void)hidenLoadingView:(LoadingView *)loadingView{

        [loadingView performSelector:@selector(hide) withObject:nil afterDelay:0.4];

    }

    //添加 背景灰度

    - (void)show{

        //添加到window上 就不需要再次添加到self.view上了

        UIWindow *win = [[UIApplication sharedApplication] keyWindow];

        UIView *topView = [win.subviews objectAtIndex:0];

        

        [topView addSubview:self];

        

        

        [UIView animateWithDuration:0.1 animations:^{

            [self layoutIfNeeded];

        }];

    }

    - (void)hide{

        

        [UIView animateWithDuration:0.1 animations:^{

            self.alpha = 0;

            

            [self layoutIfNeeded];

        } completion:^(BOOL finished) {

            [self removeFromSuperview];

        }];

    }

  • 相关阅读:
    SNAT的作用是什么
    Maven命名规范收集
    Linux下Git命令中文显示乱码的问题解决:274232350256256346200273347273223
    HttpClient中文乱码问题排查
    Ubuntu 16.04通过NetworkManager(GUI)配置网桥
    HTML5 Video P2P技术研究(转)
    CentOS 6.9下KVM虚拟机快照创建、删除、恢复(转)
    CentOS 6.9下KVM虚拟机通过virt-clone克隆虚拟机(转)
    开源规则引擎 drools
    评估系统负载
  • 原文地址:https://www.cnblogs.com/lrr0618/p/5307447.html
Copyright © 2011-2022 走看看