IOS7中UIAlertView上添加UIActivityIndicatorView提示 简单方法
2013-10-30 10:29
441 查看
.h
@interface WaitingView : UIView
@end
@interface TextAlertView :
UIView
{
UILabel *textLabel;
}
-(void)ComeInAnimation:(UIView*)superView text:(NSString*)title;
-(void)GoOutAnimation;
@end
.m
@implementation WaitingView
- (id)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
//self.backgroundColor=[UIColor grayColor];
//self.alpha=0.2;
UIView *v=[[UIView
alloc] initWithFrame:CGRectMake(320/2-30,
568/2-100,
60, 60)];
v.backgroundColor=[UIColor
darkGrayColor];
v.layer.masksToBounds =
YES;
v.layer.cornerRadius =
6.0;
v.layer.borderWidth =
1;
v.layer.borderColor = [[UIColor
whiteColor] CGColor];
[self addSubview:v];
UIActivityIndicatorView *actview = [[UIActivityIndicatorView
alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
actview.center=CGPointMake(v.frame.size.width/2, v.frame.size.height/2);
[actview startAnimating];
[v addSubview:actview];
//把 UIActivityIndicatorView
加到 UIView 中
}
return self;
}
@end
@implementation TextAlertView
- (id)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
self.backgroundColor=[UIColor
darkGrayColor];
self.layer.masksToBounds =
YES;
self.layer.cornerRadius =
0;
self.layer.borderWidth =
1.5;
self.layer.borderColor = [[UIColor
blackColor] CGColor];
textLabel=[[UILabel
alloc] initWithFrame:CGRectMake(0,
0, frame.size.width, frame.size.height)];
textLabel.textColor=[UIColor
whiteColor];
textLabel.textAlignment=NSTextAlignmentCenter;
textLabel.font=[UIFont
systemFontOfSize:12];
textLabel.backgroundColor=[UIColor
clearColor];
[self addSubview:textLabel];
}
return self;
}
-(void)ComeInAnimation:(UIView*)superView text:(NSString*)title
{
textLabel.text=title;
[superView addSubview:self];
[UIView beginAnimations:@"add"
context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self
cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.3f];
[UIView commitAnimations];
}
-(void)GoOutAnimation
{
[self
removeFromSuperview];
[UIView beginAnimations:@"remove"
context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self
cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.3f];
[UIView commitAnimations];
}
@end
初始化
加载
取消
@interface WaitingView : UIView
@end
@interface TextAlertView :
UIView
{
UILabel *textLabel;
}
-(void)ComeInAnimation:(UIView*)superView text:(NSString*)title;
-(void)GoOutAnimation;
@end
.m
@implementation WaitingView
- (id)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
//self.backgroundColor=[UIColor grayColor];
//self.alpha=0.2;
UIView *v=[[UIView
alloc] initWithFrame:CGRectMake(320/2-30,
568/2-100,
60, 60)];
v.backgroundColor=[UIColor
darkGrayColor];
v.layer.masksToBounds =
YES;
v.layer.cornerRadius =
6.0;
v.layer.borderWidth =
1;
v.layer.borderColor = [[UIColor
whiteColor] CGColor];
[self addSubview:v];
UIActivityIndicatorView *actview = [[UIActivityIndicatorView
alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
actview.center=CGPointMake(v.frame.size.width/2, v.frame.size.height/2);
[actview startAnimating];
[v addSubview:actview];
//把 UIActivityIndicatorView
加到 UIView 中
}
return self;
}
@end
@implementation TextAlertView
- (id)initWithFrame:(CGRect)frame
{
self = [super
initWithFrame:frame];
if (self) {
self.backgroundColor=[UIColor
darkGrayColor];
self.layer.masksToBounds =
YES;
self.layer.cornerRadius =
0;
self.layer.borderWidth =
1.5;
self.layer.borderColor = [[UIColor
blackColor] CGColor];
textLabel=[[UILabel
alloc] initWithFrame:CGRectMake(0,
0, frame.size.width, frame.size.height)];
textLabel.textColor=[UIColor
whiteColor];
textLabel.textAlignment=NSTextAlignmentCenter;
textLabel.font=[UIFont
systemFontOfSize:12];
textLabel.backgroundColor=[UIColor
clearColor];
[self addSubview:textLabel];
}
return self;
}
-(void)ComeInAnimation:(UIView*)superView text:(NSString*)title
{
textLabel.text=title;
[superView addSubview:self];
[UIView beginAnimations:@"add"
context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
forView:self
cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.3f];
[UIView commitAnimations];
}
-(void)GoOutAnimation
{
[self
removeFromSuperview];
[UIView beginAnimations:@"remove"
context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self
cache:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:0.3f];
[UIView commitAnimations];
}
@end
初始化
加载
取消
相关文章推荐
- Android为RecyclerView添加头部底部的简单方法
- Android给RecyclerView添加头(Header)和尾(Footer)和分标题(Title)——最简单的两种方法
- UIAlertView文字的最简单左对齐方法
- Android TextView 添加下划线的简单方法
- 为UIAlertView上的按钮添加方法,需要重写协议中对话框按钮点击事件方法
- TextView添加下划线的简单方法
- ios中UIAlert 提示框自动消失方法,超简单!
- thinkphp3.x自定义Action、Model及View的简单实现方法
- iOS系统UIPickerView的简单使用和方法属性介绍
- iPhone 上利用MKMapView实现简单地图的方法
- 【Android studio】CardView 卡片布局简单学习 和 报错的解决方法!
- C#给自己写的方法添加注释提示
- 在iOS7之后,苹果会自动给导航控制器里面的所有UIScrollView顶部都会添加额外的滚动区域64.
- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
- 给girdview添加数据、并简单分页(使用datatable作为数据源)
- Android实现简单时钟View的方法
- TextView设置LengthFilter,粘贴超长文本的时候没有提示的解决方法
- UIALertView的基本用法与UIAlertViewDelegate对对话框的事件处理方法
- 关于ViewPager中添加各个Fragment以及设置其中的组件监听器方法
- Textview添加边框方法之一