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 ...
随机推荐
- Winform基础 -- 菜单
快速创建默认菜单 使用控件 MenuStrip : 点击菜单的右上方小三角:选择 [插入标准项] 即可显现出标准的菜单格式: 如果想添加更多的菜单项,可以在 [请在此处键入] 处输入菜单项的名称 ...
- Spark安装部署
原创文章,转载请注明: 转载自www.cnblogs.com/tovin/p/3820979.html 一.系统环境配置 参照http://www.cnblogs.com/tovin/p/381890 ...
- lintcode 中等题:majority number III主元素III
题目 主元素 III 给定一个整型数组,找到主元素,它在数组中的出现次数严格大于数组元素个数的1/k. 样例 ,返回 3 注意 数组中只有唯一的主元素 挑战 要求时间复杂度为O(n),空间复杂度为O( ...
- hdu 3863 No Gambling
#include<stdio.h> int main() { int n; ) { printf("I bet on Oregon Maple~\n"); } ; } ...
- Linux进程管理知识整理
Linux进程管理知识整理 1.进程有哪些状态?什么是进程的可中断等待状态?进程退出后为什么要等待调度器删除其task_struct结构?进程的退出状态有哪些? TASK_RUNNING(可运行状态) ...
- LAMP环境 源码包安装
linux的学习很早就开始了,大学的时候的时候有有学过unix,后来每年都有去看看linux,因为在小城市的缘故,很少会实际工作中用到,基本都是智慧云之类的,同事也说,你学起来也用不上,IT生态不好, ...
- 国内为什么没有好的 Stack Overflow 的模仿者?
国内为什么没有好的 Stack Overflow 的模仿者? 个人觉得, 高端的程序员会直接上stackoverflow提问, 所以国内中文的stackoverflow必然面对低端程序员. 鉴于中国程 ...
- set集合_变长
//set可变集合 //便利初始化函数分配大小 NSMutableSet *mutableSet1 = [[NSMutableSet alloc] initWithCapacity:3]; NSMut ...
- testNG小试牛刀
testNG是一个测试框架,其灵感来自JUnit和NUnit的,但引入了一些新的功能,使其功能更强大,使用更方便. testNG是一个开源自动化测试框架:testNG表示下一代. testNG是类似于 ...
- 车牌识别LPR(五)-- 一种车牌定位法
该方法是某个文章中看到的,有点忘了是那一篇了,看的太多也太久了. Step1.把采集到的RGB图像转换为HSI图像. HSI模型能反映人对色彩的感知和鉴别能力,非常适合基于色彩的图像的相似比较,故采用 ...