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 ...
随机推荐
- hdu 1517 A Multiplication Game 博弈论
思路:求必胜区间和必败区间! 1-9 先手胜 10-2*9后手胜 19-2*9*9先手胜 163-2*2*9*9后手胜 …… 易知右区间按9,2交替出现的,所以每次除以18,直到小于18时就可以直接判 ...
- lintcode:Add Binary 二进制求和
题目: 二进制求和 给定两个二进制字符串,返回他们的和(用二进制表示). 样例 a = 11 b = 1 返回 100 解题: 和求两个链表的和很类似 考虑进位,考虑最后一项的进位 0+0 = 0 不 ...
- 教育行业SaaS选型 需要注意的三点问题
2008年经济危机席卷全球,造成世界范围内的金融动荡,国内各行业虽然都面临了不小的冲击,但是在危机面前,中国的教育行业却逆势而上,硕果累累.据统计,2008年教育行业的投资案例达18起,投资金额18. ...
- SQLite操作(C# )
C#连接SQLite的...方法 http://www.cnblogs.com/virusswb/archive/2010/09/17/SQLite1.html 1 SQLite简介 SQLite,是 ...
- 测试Tomcat
- Android Intent个人介绍
在Android中要打开一个新的Activity, 不用说,肯定会用到Intent,Intent作为Android的四大组件之一,个人理解,Intent的作用就是用来在(其它三个不同组件)间进行通讯, ...
- 极客编程必备的五大PHP开发应用
有了PHP应用可以帮助编码爱好者事半功倍,提升项目质量:有了这些最新的且灵活的PHP应用使创建编码项目更加简单.便捷.本文,我们收集了五大最新的PHP开发应用. PHP应用在网络上并不多见.最重要的是 ...
- JVM学习笔记(二)------Java代码编译和执行的整个过程
Java代码编译是由Java源码编译器来完成,流程图如下所示: Java字节码的执行是由JVM执行引擎来完成,流程图如下所示: Java代码编译和执行的整个过程包含了以下三个重要的机制: Java源码 ...
- svn: E180001: Unable to open an ra_local session to URL问题解决方案
在使用Android Studio的SVN导入项目时,出现了: svn: E180001: Unable to open an ra_local session to URLsvn: E180001: ...
- sqlserver得到昨天的数据
SELECT * FROM test where DATEDIFF(d,witdate,getdate()) = 1 witdate表示的比较字段