IOS UIActivityIndicatorView 等待指示器
自己做的一个 等待指示器
#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 等待指示器的更多相关文章
- 使用开源库 MBProgressHUD 等待指示器
source https://github.com/jdg/MBProgressHUD MBProgressHUD is an iOS drop-in class that displays a tr ...
- iOS UIActivityIndicatorView 的使用
UIActivityIndicatorView 非常简单 ,就是一个转圈圈的控件:http://blog.csdn.net/zhaopenghhhhhh/article/details/1209265 ...
- UIActivityIndicatorView活动指示器
活动指示器(UIActivityIndicatorView)可以告知用户有一个操作正在进行中.派生自UIView,所以他是视图,也可以附着在视图上. 一.创建 UIActivityIndicatorV ...
- iOS UIActivityIndicatorView
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle ...
- IOS UIActivityIndicatorView动画
● 是一个旋转进度轮,可以用来告知用户有一个操作正在进行中,一般 用initWithActivityIndicatorStyle初始化 ● 方法解析: ● - (void)startAnimating ...
- 转 UIActivityIndicatorView、UIProgressView 活动与进度指示器-IOS开发
活动指示器(UIActivityIndicatorView)可以告知用户有一个操作正在进行中.进度指示器(UIProgressView )也具有同样功能,而且还可以告知用户离操作结束还多远. 这两个指 ...
- IOS开发之XCode学习014:警告对话框和等待提示器
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能: 1.警告对话框和等待提示器的概念 2.警告对话框 ...
- IOS开发UI基础UIActivityIndicatorView的属性
UIActivityIndicatorView 1.activityIndicatorViewStyle设置指示器的样式UIActivityIndicatorViewStyleWhiteLarge U ...
- iOS - UI - UIActivityIndicatorView
1.UIActivityIndicatorView HUD 指示器 UIActivityIndicatorView * indicatorView = [[UIActivityIndicatorVie ...
随机推荐
- lintcode: 有效的括号序列
题目: 有效的括号序列 给定一个字符串所表示的括号序列,包含以下字符: '(', ')', '{', '}', '[' and']', 判定是否是有效的括号序列. 样例 括号必须依照 "() ...
- hdu 4465 Candy
题解: 由题意得 需要运用: C(m,n)=exp(logC(m,n)) f[]=; ; i<=; i++) f[i]=f[i-]+log(i*1.0); double logC(int m,i ...
- 从svn删除文件夹和文件
由于项目开始放在自己项目组的一个服务器上,而且svn也是自己在该服务器上搭建的,但是不知道是什么原因,svn上的代码被误删了.为了更稳定地使用svn,所以使用公司的svn来管理代码. 运维将不是最新版 ...
- log4j的基本配置参数
转载:http://blog.csdn.net/fengyifei11228/article/details/6070006 log4j配置文件有三个主要的组件:Logger,Appender和Lay ...
- python各种类型转换-int,str,char,float,ord,hex,oct等
int(x [,base ]) 将x转换为一个整数 long(x [,base ]) 将x转换为一个长整数 float(x ) 将x转换到 ...
- CString, QString, char*之间的转换(包括VC编译开关)
传给未分配内存的const char* (LPCTSTR)指针. CString cstr(asdd); const char* ch = (LPCTSTR)cstr; ch指向的地址和cstr相同. ...
- java:对象的转型
面向对象编程有三个特征,即封装.继承和多态,学习多态必须了解向上转型和向下转型. 一.向上转型:将子类对象赋值给父类的引用 动物 a=new 狗()://这就为向上转型 向上转型都会成功,是安全的. ...
- 让你了解x86的中断
COPY FROM:http://zhan.renren.com/qdlinux?gid=3602888498000980107&from=post&checked=true 研究li ...
- C# 静态类 + c# 访问器 用途
C# 静态类 http://blog.csdn.net/dodream/article/details/4588498 静态类的主要特性:仅包含静态成员. 无法实例化. 是密封的. 不能包含实例 ...
- sql partition by 的使用
select a.bs_sn, a.bs_bd_no, a.bs_bk_code, a.bs_kind_no, a.bs_flag, b.det_flag, c.bp_in_no, c.bp_name ...