zoukankan      html  css  js  c++  java
  • 封装 加载loading动画

    #import <UIKit/UIKit.h>

     @interface SSLoading : UIView

     - (instancetype)initWithFrame:(CGRect)frame;

    - (void)showLoading:(UIColor *)backgroundColor alpha:(CGFloat)alpha;

    -(void)disMiss;

     @end

     

     

    #import "SSLoading.h"

    #import "UIImage+GIF.h"

     

     

    @implementation SSLoading

    {

        UIView *SSLoadingBackView;

        UIImageView *SSLoadingImageView;

    }

    - (instancetype)initWithFrame:(CGRect)frame

    {

        self = [super initWithFrame:frame];

        if (self) {

            self.hidden = YES;

            self.frame = frame;

        }

        return self;

     

    }

     

    - (void)showLoading:(UIColor *)backgroundColor alpha:(CGFloat)alpha

    {

        

        self.hidden = NO;

        

        SSLoadingBackView = [[UIView alloc] initWithFrame:self.frame];

        SSLoadingBackView.backgroundColor = backgroundColor;

        SSLoadingBackView.alpha = alpha;

        [self addSubview:SSLoadingBackView];

        

        NSString  *name = @"loading@2x.gif";

        NSString  *filePath = [[NSBundle bundleWithPath:[[NSBundle mainBundle] bundlePath]] pathForResource:name ofType:nil];

        NSData  *imageData = [NSData dataWithContentsOfFile:filePath];

        if (!SSLoadingImageView) {

            SSLoadingImageView = [[UIImageView alloc]init];

        }

        

        SSLoadingImageView.backgroundColor = [UIColor clearColor];

        SSLoadingImageView.image = [UIImage sd_animatedGIFWithData:imageData];

        SSLoadingImageView.frame = CGRectMake(self.frame.size.width/2-50, self.frame.size.height/2-50, 100, 100);

        SSLoadingImageView.contentMode = UIViewContentModeScaleAspectFit;

        [self addSubview:SSLoadingImageView];

    }

     

    -(void)disMiss

    {

        

        for (UIView *view in self.subviews) {

            [view removeFromSuperview];

        }

        self.hidden = YES;

    }

  • 相关阅读:
    How to Get Started With AIOps
    第六部分 实现细节
    第一部分 概览
    第五部分 软件架构
    vs2010 sqlite guid 问题
    cordova(phonegap)+qjm 一统天下
    jQuery调用WebServices总是出错问题解决
    phonegap中http链接自动调用本地浏览器解决办法
    MSSQL省市数据库
    博客的第一篇
  • 原文地址:https://www.cnblogs.com/xiaolingling1126/p/5485062.html
Copyright © 2011-2022 走看看