LoadingView
//
// LoadingView.h
// 蓝桥播报
//
// Created by 小小建 on 15/7/10.
// Copyright (c) 2015年 蓝桥. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface LoadingView : NSObject
{
UIView *_backGroundView;
UIView *_centerLoadingView;
UIActivityIndicatorView *_activityView;
}
+(LoadingView *)shareLoadingView;
-(void)show;
-(void)hide;
@end
//
// LoadingView.m
// 蓝桥播报
//
// Created by 小小建 on 15/7/10.
// Copyright (c) 2015年 蓝桥. All rights reserved.
//
#import "LoadingView.h"
#import "AppDelegate.h"
static LoadingView *singleInstance=nil;
@implementation LoadingView
+(LoadingView *)shareLoadingView{
@synchronized(self){
if (singleInstance==nil) {
singleInstance=[[self alloc] init];
}
}
return singleInstance;
}
-(void)show{
AppDelegate *delegate=(AppDelegate *)[UIApplication sharedApplication].delegate;
_backGroundView=[[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[_backGroundView setBackgroundColor:[UIColor blackColor]];
_backGroundView.alpha=0.6;
[delegate.window addSubview:_backGroundView];
_centerLoadingView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];
_centerLoadingView.center=CGPointMake([UIScreen mainScreen].bounds.size.width/2, [UIScreen mainScreen].bounds.size.height/2);
UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 150, 150)];
[imgView setImage:[UIImage imageNamed:@"loading_bg.png"]];
_activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
_activityView.center = CGPointMake(imgView.frame.size.width/2, imgView.frame.size.height/2-20);
_activityView.hidesWhenStopped = YES;
[_activityView startAnimating];
[imgView addSubview:_activityView];
UILabel *labelInfo = [[UILabel alloc] initWithFrame:CGRectMake(0,0, 140, 60)];
labelInfo.center=CGPointMake(imgView.frame.size.width/2, imgView.frame.size.height/2+20);
labelInfo.numberOfLines = 2;
labelInfo.backgroundColor = [UIColor clearColor];
labelInfo.textAlignment = NSTextAlignmentCenter;
labelInfo.textColor = [UIColor whiteColor];
labelInfo.font = [UIFont systemFontOfSize:16];
labelInfo.text=@"加载中...";
[imgView addSubview:labelInfo];
[_centerLoadingView addSubview:imgView];
[delegate.window addSubview:_centerLoadingView];
}
-(void)hide{
[_activityView stopAnimating];
[_centerLoadingView removeFromSuperview];
[_backGroundView removeFromSuperview];
}
@end
LoadingView的更多相关文章
- Android showing LoadingView or EmptyView for Activity or Fragment
这几天利用一些时间,整理了一下,写了一个简单的工具类,用来快速的显示LoadingView或者EmptyView,以前都是定义一个layout,根布局为FrameLayout,再在layout布局文件 ...
- LoadingView 自定义加载图片
#import <UIKit/UIKit.h> @interface LoadingView : UIView @property (nonatomic,strong) NSMutable ...
- Android 自定义通用的loadingview
介绍 好久没有写博客啦,最近在接近新年了,年前的工作都要收尾,所以特别忙,周末抽空写了个通用的加载view,写篇博客分享出来. 功能 1.显示加载视图,加载失败的时候显示加载失败视图,数据为空时显示数 ...
- (Android自定义View)来来来,一起再撸一个Material风格loadingView。
本文同步自博主的个人博客wing的地方酒馆 很久很久以前,撸了一款loadingview(点击这里回顾),当时觉得还不错,现在看看觉得好丑啊!!! 于是想再撸一个,无意间在这里看到一个很不错的效果,于 ...
- 手把手教你画一个 逼格满满圆形水波纹loadingview Android
才没有完结呢o( ̄︶ ̄)n .大家好,这里是番外篇. 拜读了爱哥的博客,又学到不少东西.爱哥曾经说过: 要站在巨人的丁丁上. 那么今天,我们就站在爱哥的丁丁上来学习制作一款自定义view(开个玩笑,爱 ...
- 自定义控件---loadingView
自定义加载框,效果如图: 这个loadingView可以在图片下添加文案(加载中...),还可以自定义动画效果,自定义布局文件,屏蔽用户操作,点击返回键后隐藏. 库类中包含了一个LoadingDial ...
- 三角函数之美-水波纹载入LoadingView
一.前言 学习是要总结的.近期几天学习了画图相关的,可是使用的机会较少,如今又快要遗忘了,这次看了水波纹的绘制.认为十分有意思,还是 把实现的方法记录下来.技术无他,为手熟尔.还是要多练习,空淡误国, ...
- HarmonyOS三方件开发指南(15)-LoadingView功能介绍
目录: 1. LoadingView组件功能介绍2. Lottie使用方法3. Lottie开发实现4.<HarmonyOS三方件开发指南>系列文章合集 1. LoadingView组件功 ...
- iOS开发系列--Swift进阶
概述 上一篇文章<iOS开发系列--Swift语言>中对Swift的语法特点以及它和C.ObjC等其他语言的用法区别进行了介绍.当然,这只是Swift的入门基础,但是仅仅了解这些对于使用S ...
随机推荐
- Mysql Master-slave 主从配置
MySQL主从复制 场景描述:主数据库服务器:192.168.10.130,MySQL已经安装,并且无应用数据.从数据库服务器:192.168.10.131,MySQL已经安装,并且无应用数据. 2. ...
- MD5 加密
字符串加密 // 1. 准备好一个字符串 NSString *string = @"asdasfaf"; // 2. MD5加密是基于C语言的. 所以要把这个字符串转化成C的字符串 ...
- thinkphp 3.2.3 session 丟失問題
之前做的几个 站session在跨页时也不会丢失(都在同一台服务器,所以我排除了服务器配置问题),这次居然很奇怪的发生的,在火狐上有,在ie, 谷哥上没有session,看了很多网上的贴子 其中有一个 ...
- Delphi控件之---通过编码学习TStringGrid(也会涉及到Panel控件,还有对Object Inspector的控件Events的介绍
我是参考了万一的博客里面的关于TStringGrid学习的教程,但是我也结合自己的实际操作和理解,加入了一些个人的补充,至少对我有用! 学用TStringGrid之——ColCount.RowCoun ...
- 【Java EE 学习 83 下】【SpringMVC】【使用注解替代已过时的API】【SpringMVC、Hibernate整合】
一.SpringMVC中注解的使用 1.为什么要使用注解 之前曾经提到过的三种控制器在spring3.0中都已经被明确标记为过时了,spring3.0推荐使用注解的方式替代三种控制器,实际上使用注解的 ...
- GruntJS学习(转)
GruntJS 是基于JavaScript的命令行构建工具,它可以帮助开发者们自动化重复性的工作.你可以把它看成是JavaScript下的Make或者Ant.它可以完成诸如精简.编译.单元测试.lin ...
- Js(DOM) 和Jq 对象的相互转换
JQuery 对象不能使用DOM对象中的方法,同样,Dom对象 不能使用JQuery 中的方法,但有时候 ,我们不得不使用JQuery的方法或者 Dom对象的方法,该怎么办呢? 下面介绍一下 jq对象 ...
- Android-Spinner [使用C# And Java实现]
效果如下: C#实现代码 using Android.App; using Android.OS; using Android.Widget; namespace SpinnerDemo { [Act ...
- 如何理解typedef void (*pfun)(void)
问题: 在刚接触typedef void (*pfun)(void) 这个结构的时候,存在疑惑,为什么typedef后只有一"块"东西,而不是两"块"东西呢?那 ...
- 未能加载文件或程序集“Microsoft.ReportViewer.WinForms 解决办法
异常信息: 未能加载文件或程序集“Microsoft.ReportViewer.WinForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken= ...