• 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];

        }];

    }

  • 相关阅读:
    MySQL数据库的主从同步
    学习Java必看的Java书籍(高清中文最新版附下载链接)
    servlet重点知识总结
    JUnit & JMockit单元测试
    mongodb重点知识总结
    Quartz学习总结
    IDEA使用总结
    bat脚本知识总结
    linux shell脚本相关知识
    SpringMVC重点知识总结
  • 原文地址:https://www.cnblogs.com/lrr0618/p/5307447.html
Copyright © 2020-2023  润新知