IOS7中UIAlertView上添加UIActivityIndicatorView提示 简单方法

来源:互联网 发布:网络电影分账比例 编辑:程序博客网 时间:2024/06/03 22:37

.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=[[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 =1;

        v.layer.borderColor = [[UIColorwhiteColor] CGColor];

        [self addSubview:v];


        UIActivityIndicatorView *actview = [[UIActivityIndicatorViewalloc] 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=[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];

    }

    return self;

}


-(void)ComeInAnimation:(UIView*)superView text:(NSString*)title

{

    textLabel.text=title;

    [superView addSubview:self];

    [UIView beginAnimations:@"add"context:nil];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeftforView:selfcache:YES];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

    [UIView setAnimationDuration:0.3f];

    [UIView commitAnimations];

}

-(void)GoOutAnimation

{

    [selfremoveFromSuperview];

    [UIView beginAnimations:@"remove"context:nil];

    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRightforView:selfcache:YES];

    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

    [UIView setAnimationDuration:0.3f];

    [UIView commitAnimations];

}


@end



初始化

加载


取消

原创粉丝点击