自己做的一个 等待指示器

#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. hdu 4447 Yuanfang, What Do You Think?

    思路: 这题有个结论也可以自己归纳: 对于给定的n,其约数用pi表示 T(n)=T(p1)T(p2)……T(pn)T(n') 其中T(n')是这个式子所独有的也就是 T(n')=(x^n-1)/T(p ...

  2. Project Euler 96:Su Doku 数独

    Su Doku Su Doku (Japanese meaning number place) is the name given to a popular puzzle concept. Its o ...

  3. s3cmd的安装与配置

    安装包链接:http://files.cnblogs.com/files/litao0505/s3.rar 安装S3cmd1. tar -zxf s3cmd-1.0.0.tar.gz2. mv s3c ...

  4. [翻译] - <Entity Framework> - 直接执行数据库命令

    原文:[翻译] - <Entity Framework> - 直接执行数据库命令 纯属学习上的记录, 非专业翻译, 如有错误欢迎指正! 原文地址: http://msdn.microsof ...

  5. 10个用于Web开发的最好 Python 框架

    Python 是一门动态.面向对象语言.其最初就是作为一门面向对象语言设计的,并且在后期又加入了一些更高级的特性.除了语言本身的设计目的之外,Python标准 库也是值得大家称赞的,Python甚至还 ...

  6. (六)CSS伪元素

    CSS伪元素用于向某些选择器设置特殊效果. 伪元素的用法和伪类相似: selector:pseudo-element {property:value;} CSS类也可以与伪元素配合使用: select ...

  7. The type xxx cannot be resolved. It is indirectly referenced from required .class files

    项目A中引入一个jar包B,在项目A中调用项目B,出现如下错误提示:   大致意思是:这上面所需的包是间接引用的,即A项目调用B项目,B项目又引用了另外一个包C,而这个包现在不在你的A项目的引用中. ...

  8. 【Todo】深入理解Javascript系列

    真的很好,要看 http://www.cnblogs.com/TomXu/archive/2011/12/15/2288411.html

  9. disable-linux-firewall-under-centos-rhel-fedora

    http://www.cyberciti.biz/faq/disable-linux-firewall-under-centos-rhel-fedora/

  10. 纯tarjan poj2186

    tarjan,叙叙旧咯 #include<cstdio>#define maxn 50005int e[maxn],ne[maxn],be[maxn],all;int DFN[maxn], ...