您的位置:首页 > 产品设计 > UI/UE

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





初始化



加载



取消
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: