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: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



初始化

加载


取消

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值