IOS7中UIAlertView上新增UIActivityIndicatorView提示 簡單方法
.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
if (self) {
//self.backgroundColor=[UIColor grayColor];
//self.alpha=0.2;
UIView *v=[[UIViewalloc] initWithFrame:CGRectMake(320/2-30, 568/2-100, 60, 60)];
v.backgroundColor=[UIColordarkGrayColor];
v.layer.masksToBounds = YES;
v.layer.cornerRadius = 6.0;
v.layer.borderWidth =
v.layer.borderColor = [[UIColorwhiteColor] CGColor];
[self addSubview:v];
UIActivityIndicatorView *actview = [[UIActivityIndicatorViewalloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
actview.center=CGPointMake(v.frame.size.width/2, v.frame.size.
[actview startAnimating];
[v addSubview:actview];
//把 UIActivityIndicatorView 加到 UIView 中
}
returnself;
}
@end
@implementation TextAlertView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor=[UIColordarkGrayColor];
self.layer.masksToBounds = YES;
self.layer.cornerRadius = 0;
self.layer.borderWidth = 1.5;
self.layer.borderColor = [[UIColorblackColor] CGColor];
textLabel=[[UILabelalloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
textLabel.textColor=[UIColorwhiteColor];
textLabel.textAlignment=NSTextAlignmentCenter;
textLabel.font=[UIFontsystemFontOfSize:12];
textLabel.backgroundColor=[UIColorclearColor];
[self addSubview:textLabel];
}
returnself;
}
-(void)ComeInAnimation:(UIView*)superView text:(NSString*)title
{
textLabel.text=title;
[superView addSubview:self];
[UIViewbeginAnimations:@"add"context:nil];
[UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromLeftforView:selfcache:YES];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseOut];
[UIViewsetAnimationDuration:0.3f];
[UIViewcommitAnimations];
}
-(void)GoOutAnimation
{
[selfremoveFromSuperview];
[UIViewbeginAnimations:@"remove"context:nil];
[UIViewsetAnimationTransition:UIViewAnimationTransitionFlipFromRightforView:selfcache:YES];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseOut];
[UIViewsetAnimationDuration:0.3f];
[UIViewcommitAnimations];
}
@end
初始化
載入
取消