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 ...
随机推荐
- VirtualBox 给虚拟机绑定IP
在VirtualBox中,有时候打开虚拟机,会出现Waiting for 60 seconds more for network configuration这种情况,从而使得开机变得很慢. 通过以下操 ...
- 如何在Mininet中修改host的IP地址
how to update virtual host's IP in mininet? I got it! do like this: mininet> py h1.setIP('10.0.0. ...
- apache common-io.jar FileUtils
//复制文件 void copyFile(File srcFile, File destFile) //将文件内容转化为字符串 String readFileToString(File file ...
- c/c++优秀博文
C进阶指南(1):整型溢出和类型提升.内存申请和管理 http://blog.jobbole.com/72830/ 软件开发中应避免的10个问题
- JDK安装配置问题
JDK安装过程中会有两个安装提示,一个是jdk的安装,一个是jre的安装
- python 利用smtp发送邮件,html格式
def send_mail(to_list, sub, context):#sentmail to the maillist ''' to_list: 发送给谁 sub: 主题 context: 内容 ...
- SQLite数据库的体系结构(翻译自sqlite.org)
$1 简介 本文档描述了SQLite库的体系结构,这些信息对那些想理解和修改SQLite的内部工作机制的人是有用的. 下图显示了SQLite的主要组成部件及其相互关系,下面的内容将描述每一 ...
- linux shell 命令学习(1) du- estimate file space usage
du - estimate file space usage , 计算文件的磁盘大小 语法格式: du [OPTION] ... [FILE] 描述: 汇总每个文件的磁盘大小, 递归汇总目录的大小, ...
- C++:类的创建
类的创建 #include<iostream> #include<cmath> using namespace std; class Complex //声明一个名为Compl ...
- Linux Shell 工作原理
Linux系统提供给用户的最重要的系统程序是Shell命令语言解释程序.它不属于内核部分,而是在核心之外,以用户态方式运行.其基本功能是解释并执行用户打入的各种命令,实现用户与Linux核心的接口.系 ...