一,效果图。

二,工程图。

三, 代码。

ViewController.h

#import <UIKit/UIKit.h>
//loading
#import "GPLoadingButton.h" @interface ViewController : UIViewController
{
//loading
GPLoadingButton *loadingButton;
UIView *backViewLoad;
} @end

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. //loading
[self addLoadingView];
}
//点击任何处,loading出现
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
backViewLoad.hidden=NO;
loadingButton.hidden=NO;
[loadingButton startActivity];
//5s后loading消失
[self performSelector:@selector(loadingStop) withObject:nil afterDelay:2];
}
-(void)loadingStop
{
backViewLoad.hidden=YES;
loadingButton.hidden=YES;
[loadingButton stopActivity];
}
#pragma -mark --loading------
-(void)addLoadingView
{
backViewLoad=[[UIView alloc]initWithFrame:CGRectMake(0, 0,self.view.frame.size.width, self.view.frame.size.height)];
backViewLoad.backgroundColor=[UIColor blackColor];
backViewLoad.alpha=0.7;
backViewLoad.hidden=YES;
[self.view addSubview:backViewLoad]; loadingButton = [[GPLoadingButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width/2-20, (self.view.frame.size.height-38)/2-20, 40, 40)];
loadingButton.rotatorColor = [UIColor colorWithRed:59/255.0 green:89/255.0 blue:152/255.0 alpha:1.0];
loadingButton.hidden=YES;
[self.view addSubview:loadingButton]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

【代码笔记】iOS-自定义loading的更多相关文章

  1. iOS 自定义导航栏笔记

    一.UINavigationBar的结构 导航栏几乎是每个页面都会碰到的问题,一般两种处理方式:1.隐藏掉不显示 2.自定义 1. 添加导航栏 TestViewController * mainVC ...

  2. 【iOS自定义键盘及键盘切换】详解

    [iOS自定义键盘]详解 实现效果展示: 一.实现的协议方法代码 #import <UIKit/UIKit.h> //创建自定义键盘协议 @protocol XFG_KeyBoardDel ...

  3. Cocos2d-JS 自定义loading界面

    [转]http://blog.csdn.net/et_sandy/article/details/41415047 环境: win7 64位 Cocos2d-JS v3.1 Cocos Code ID ...

  4. 笔记-iOS 视图控制器转场详解(上)

    这是一篇长文,详细讲解了视图控制器转场的方方面面,配有详细的示意图和代码,为了使得文章在微信公众号中易于阅读,seedante 辛苦将大量长篇代码用截图的方式呈现,另外作者也在 Github 上附上了 ...

  5. iOS自定义的UISwitch按钮

    UISwitch开关控件 开关代替了点选框.开关是到目前为止用起来最简单的控件,不过仍然可以作一定程度的定制化. 一.创建 UISwitch* mySwitch = [[ UISwitchalloc] ...

  6. IOS开发笔记 IOS如何访问通讯录

    IOS开发笔记  IOS如何访问通讯录 其实我是反对这类的需求,你说你读我的隐私,我肯定不愿意的. 幸好ios6.0 以后给了个权限控制.当打开app的时候你可以选择拒绝. 实现方法: [plain] ...

  7. Hadoop学习笔记—5.自定义类型处理手机上网日志

    转载自http://www.cnblogs.com/edisonchou/p/4288737.html Hadoop学习笔记—5.自定义类型处理手机上网日志 一.测试数据:手机上网日志 1.1 关于这 ...

  8. <Python Text Processing with NLTK 2.0 Cookbook>代码笔记

    如下是<Python Text Processing with NLTK 2.0 Cookbook>一书部分章节的代码笔记. Tokenizing text into sentences ...

  9. OpenGL ES: iOS 自定义 UIView 响应屏幕旋转

    iOS下使用OpenGL 如果使用GLKit View 那么不用担心屏幕旋转的问题,说明如下: If you change the size, scale factor, or drawable pr ...

  10. 自定义loading效果

    结合Font Awesome字体图标自定义loading效果 Font Awesome字体图标地址:http://www.fontawesome.com.cn/faicons/ 使用javascrip ...

随机推荐

  1. Python小白学习之路(二十三)—【生成器补充】

    生成器的一些补充 接着下鸡蛋和吃包子! 补充一:生成器只能遍历一次 (总是把生成器比喻成母鸡下鸡蛋,需要一个下一个,首先是下出来的鸡蛋不能塞回母鸡肚子里,其次是一个母鸡一生只能下一定数量的鸡蛋,下完了 ...

  2. Vue的声明周期

    以下简单介绍,以自己的理解进行分析.如有不好,请大牛勿喷!!!!!! new Vue() 创建 Vue 实例 beforeCreate(){}: 第一生命周期 表示实例完全创建出来,此函数执行是,da ...

  3. 12-01 Java Scanner类,Scanner类中的nextLine()产生的换行符问题

    分析理解:Scanner sc = new Scanner(System.in); package cn.itcast_01; /* * Scanner:用于接收键盘录入数据. * * 前面的时候: ...

  4. odoo开发笔记 -- odoo web机制浅析

    http://blog.csdn.net/M0relia/article/details/39025947

  5. mvn cli 搭建项目架构

    创建如图所示目录结构 在system-parent创建如下目录 ├─system-dao ├─system-domain ├─system-service └─system-web 创建system- ...

  6. python使用(五)

    1.shell_option.py 2.db_option.py 1.shell_option.py # coding=utf8 __author__ = 'SummerChill' import o ...

  7. / | \ # $ ^ & *这些符号怎么读

    供参考: /: slash或forward slash 英 [slæʃ] |: vertical bar或pipe #: number sign或pound sign \: backslash 英 [ ...

  8. 多线程之CountDownLatch和CyclicBarriar使用

    CountDownLatch和CyclicBarriar是java.util.concurrent包下面提供的多线程同步工具,两者有点相似,相当于计数器,但是用处还是有区别的. CountDownLa ...

  9. 七、Framework类库

    1.Framework类库简介 .Net Framework类库包含Framework类库(Framework Class Library,FCL).FCL是一组DLL程序集的统称,其中含有数千个类型 ...

  10. Choose GitLab for your next open source project

    原文:https://b.agilob.net/choose-gitlab-for-your-next-project/ GitLab.com is a competitor of GIthub. I ...