自己做的一个 等待指示器

#import <UIKit/UIKit.h>

@interface RockIndicatorView : UIView

{

}

@property(nonatomic,strong) UIView * indBgView;

@property(nonatomic,strong) UIActivityIndicatorView * indView;

@property(nonatomic,strong) UILabel * textLabel;

+(void)showWihtParent:(UIView * )parentView;

+(void)dismiss;

@end

//////////////////////////////////////////////////////////////////////////////////////////////////////

//

//  RockIndicatorView.m

//  test_demo

//

//  Created by zhuang chaoxiao on 14-5-18.

//  Copyright (c) 2014年 zhuang chaoxiao. All rights reserved.

//

#import "RockIndicatorView.h"

@implementation RockIndicatorView

- (id)initWithFrame:(CGRect)frame

{

self = [super initWithFrame:frame];

if (self) {

// Initialization code

self.backgroundColor = [UIColorclearColor];

self.frame = [[UIScreen mainScreen] bounds];

self.userInteractionEnabled = NO;

}

returnself;

}

+(RockIndicatorView*)shareView

{

static RockIndicatorView * indView = nil;

staticdispatch_once_t  once;

dispatch_once(&once , ^(void){

indView = [[RockIndicatorViewalloc]initWithFrame:[[UIScreenmainScreen] bounds]];

});

return indView;

}

-(UILabel*)textLabel

{

if( _textLabel == nil )

{

CGRect rect = CGRectMake(0, 0, 50, 12);

_textLabel = [[UILabel alloc]initWithFrame:rect];

_textLabel.text = @"加载中...";

_textLabel.font = [UIFont systemFontOfSize:10];

_textLabel.textColor = [UIColor whiteColor];

[self.indBgViewaddSubview:_textLabel];

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStylealloc]init];

paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;

NSDictionary *attributes = @{NSFontAttributeName:[UIFontsystemFontOfSize:10], NSParagraphStyleAttributeName:paragraphStyle.copy};

CGSize labelSize = [_textLabel.textboundingRectWithSize:CGSizeMake(50,12) options:NSStringDrawingUsesLineFragmentOriginattributes:attributes context:nil].size;

labelSize.height = ceil(labelSize.height);

labelSize.width = ceil(labelSize.width);

_textLabel.frame = CGRectMake(0, 0, labelSize.width, labelSize.height);

_textLabel.center = CGPointMake(self.indBgView.frame.size.width/2, self.indBgView.frame.size.height/2+10);

}

return  _textLabel;

}

-(UIView *)indBgView

{

if( _indBgView == nil )

{

CGRect rect = CGRectMake(0, 0, 60, 60);

_indBgView = [[UIView alloc]initWithFrame:rect];

rect = [[UIScreen mainScreen] bounds];

_indBgView.backgroundColor = [UIColorblackColor];

_indBgView.center = CGPointMake(rect.origin.x + rect.size.width/2, rect.origin.y + rect.size.height/2);

_indBgView.userInteractionEnabled = NO;

_indBgView.alpha = 0;

_indBgView.layer.cornerRadius = 10.0f;

[self addSubview:_indBgView];

}

return_indBgView;

}

-(UIActivityIndicatorView*)indView

{

if( _indView == nil )

{

CGRect rect = CGRectMake(0, 0, 60, 60);

_indView = [[UIActivityIndicatorViewalloc]initWithFrame:rect];

_indView.center = CGPointMake(self.indBgView.frame.size.width/2, self.indBgView.frame.size.height/2 - 10);

[self.indBgViewaddSubview:_indView];

}

return_indView;

}

-(void)showAnimWithParent:(UIView*)parentView

{

[parentView addSubview:self];

[self.indViewstartAnimating];

if( self.textLabel ){}

dispatch_async(dispatch_get_main_queue(), ^(void)

{

[self.indView startAnimating];

[UIView animateWithDuration:1.0f animations:^(void)

{

self.indBgView.alpha = 1.0f;

}];

});

}

-(void)dismissFromParent

{

dispatch_async(dispatch_get_main_queue(), ^(void)

{

[UIView animateWithDuration:1.0f animations:^(void)

{

self.indBgView.alpha = 0.0f;

} completion:^(BOOL finished)

{

if( finished )

{

[self removeFromSuperview];

}

}];

});

}

+(void)showWihtParent:(UIView * )parentView

{

[[RockIndicatorViewshareView] showAnimWithParent:parentView];

}

+(void)dismiss

{

[[RockIndicatorViewshareView] dismissFromParent];

}

/*

// Only override drawRect: if you perform custom drawing.

// An empty implementation adversely affects performance during animation.

- (void)drawRect:(CGRect)rect

{

// Drawing code

}

*/

@end

IOS UIActivityIndicatorView 等待指示器的更多相关文章

  1. 使用开源库 MBProgressHUD 等待指示器

    source https://github.com/jdg/MBProgressHUD MBProgressHUD is an iOS drop-in class that displays a tr ...

  2. iOS UIActivityIndicatorView 的使用

    UIActivityIndicatorView 非常简单 ,就是一个转圈圈的控件:http://blog.csdn.net/zhaopenghhhhhh/article/details/1209265 ...

  3. UIActivityIndicatorView活动指示器

    活动指示器(UIActivityIndicatorView)可以告知用户有一个操作正在进行中.派生自UIView,所以他是视图,也可以附着在视图上. 一.创建 UIActivityIndicatorV ...

  4. iOS UIActivityIndicatorView

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle ...

  5. IOS UIActivityIndicatorView动画

    ● 是一个旋转进度轮,可以用来告知用户有一个操作正在进行中,一般 用initWithActivityIndicatorStyle初始化 ● 方法解析: ● - (void)startAnimating ...

  6. 转 UIActivityIndicatorView、UIProgressView 活动与进度指示器-IOS开发

    活动指示器(UIActivityIndicatorView)可以告知用户有一个操作正在进行中.进度指示器(UIProgressView )也具有同样功能,而且还可以告知用户离操作结束还多远. 这两个指 ...

  7. IOS开发之XCode学习014:警告对话框和等待提示器

    此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能:  1.警告对话框和等待提示器的概念 2.警告对话框 ...

  8. IOS开发UI基础UIActivityIndicatorView的属性

    UIActivityIndicatorView 1.activityIndicatorViewStyle设置指示器的样式UIActivityIndicatorViewStyleWhiteLarge U ...

  9. iOS - UI - UIActivityIndicatorView

    1.UIActivityIndicatorView HUD 指示器 UIActivityIndicatorView * indicatorView = [[UIActivityIndicatorVie ...

随机推荐

  1. chmod命令详细用法

    指令名称 : chmod 使用权限 : 所有使用者 使用方式 : chmod [-cfvR] [--help] [--version] mode file... 说明 : Linux/Unix 的档案 ...

  2. Mysql 1030 Got error -1 from storage engine 错误解决

    检查你的my.cnf或my.ini,里面会有一个参数innodb_force_recovery,你看看他的值,默认是没有这个参数,没有的话,他的默认值是0,这个参数的值如果大于0,innodb会被禁止 ...

  3. hdu1875

    http://acm.hdu.edu.cn/showproblem.php?pid=1875 2 2 10 10 20 20 3 1 1 2 2 1000 1000 给定坐标 //最小生成树 #inc ...

  4. python对json的相关操作

    什么是json: JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.易于人阅读和编写.同时也易于机器解析和生成.它基于JavaScript Programm ...

  5. C语言复习笔记-17种小算法-解决实际问题

    判断日期为一年中的第几天(考虑闰年) 1 /* 2 * 计算该日在本年中是第几天,注意闰年问题 3 * 以3月5日为例,应该先把前两个月的加起来,然后再加上5天即本年的第几天 4 * 特殊情况,闰年且 ...

  6. eclipse怎么集成配置JDK和Tomcat

    eclipse怎么集成配置JDK和Tomcat_电脑软件_百度经验http://jingyan.baidu.com/album/db55b609ab6a1f4ba30a2f2c.html?picind ...

  7. 百度网盘,前几天刚从百度云改名过来,百度云这个名字给之前的百度开放云(同步盘用户比较小众)good

    作者:黑郁金香链接:http://www.zhihu.com/question/51803053/answer/127562835来源:知乎著作权归作者所有,转载请联系作者获得授权. 在8月网盘大面积 ...

  8. Delphi 中的 procedure of object (类方法存在一个隐藏参数self),简单深刻 good

    其实要了解这些东西,适当的学些反汇编,WINDOWS内存管理机制,PE结构,看下李维的VCL架构剖析可以很好理解type TMyEvent = procedure of object;这是一种数据类型 ...

  9. chm文件访问提示:已取消到该网页的导航

    chm文件访问提示:已取消到该网页的导航或不能链接网页 解决方案: 右击chm文件,选择:属性->解除锁定 ,再重新打开文件即可

  10. Tomcat的SessionID引起的Session Fixation和Session Hijacking问题

    上一篇说到<Spring MVC防御CSRF.XSS和SQL注入攻击>,今天说说SessionID带来的漏洞攻击问题.首先,什么是Session Fixation攻击和Session Hi ...