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

        }];

    }

  • 相关阅读:
    prepareSlideshow函数
    moveElement函数与positionMessage函数
    function styleElementSiblings函数与 addClass函数
    stribeTables函数与highlightRows函数
    确定股票见底的六大信号
    调整期六招教你猎杀未来牛股
    王者-甄别同一板块强弱股的方法【真假美猴王】
    王者--分时图五要素教你抓涨停板股票
    王者-【注册制将利好哪些股票】
    王者--看盘口特点猎杀强庄股
  • 原文地址:https://www.cnblogs.com/lrr0618/p/5307447.html
Copyright © 2011-2022 走看看