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 ...
随机推荐
- linux下用非root用户重启导致ssh无法连接的问题
问题描述 安装好了centOS服务器,一直用Secure CRT工具通过ssh服务来远程连接linux,很方便的进行各种操作.今天偶然尝试了一下在非root的一般用户下执行重启服务器的命令,发现一般用 ...
- 毕向东JAVA视频讲解(第七课)
构造函数:构建创造对象时调用的函数.作用:可以给对象进行初始化. 创建对象都必须要通过构造函数初始化. 一个类中如果没有定义过构造函数,那么该类中会有一个默认的空参数构造函数. 如果在类中定义了指定的 ...
- 缓存初解(三)---Spring3.0基于注解的缓存配置+Ehcache和OScache
本文将构建一个普通工程来说明spring注解缓存的使用方式,关于如何在web应用中使用注解缓存,请参见: Spring基于注解的缓存配置--web应用实例 一.简介 在spring的modules包中 ...
- Nhibernate
Nhibernate入门与demo 学习和使用Nhibernate已经很久了,一直想写点东西和大家一起学习使用Nhibernate.博客园里也有很多大牛写了很多关于Nhibernate入门的文章.其中 ...
- 获取其它进程窗口中的状态栏信息(FindWindowEx GetWindowThreadProcessId OpenProcess SendMessage轮番轰炸)
HWND hWnd = ::FindWindow(NULL, _T("XXXXX")); if(NULL == hWnd) { return ; } HWND hWndStatus ...
- java:装饰者模式,节点流和处理流
接口: interface Worker { public void dowork(); } 清洁工:被装饰者,节点流 class Clean implements Worker { public v ...
- JDBC学习总结(五)
取得数据库连接是件耗时间及资源的动作,尽量利用已打开的连接,也就是重复利用取得的Connection实例,是改善数据库连接性能的一个方式,而采用连接池是基本做法.由于取得Connection的方式根据 ...
- 网站TCP链接暴增
昨天上线后,TCP链接暴增,红点增多. 问题在查.其中有一部分,多线程修改,突破了线程数 64的限制.线程内,会发起网络请求. 怀疑是热点之一.其他的部分也有修改,也被怀疑.准备下次,2部分分开上线. ...
- Android开发之单例模式
参考:http://blog.csdn.net/guolin_blog/article/details/8860649 http://www.cnblogs.com/liyiran/p/5283690 ...
- Android studio在真机上进行调试
1.在Android Studio中,把app的默认启动目标改为USB device,点击[app]→[app configuration],在[Target Device]选择[USB device ...