旋转进度条 WaitView

来源:互联网 发布:sql update批量更新 编辑:程序博客网 时间:2024/05/17 08:55



WaitView.h


#import <Foundation/Foundation.h>

@interface WaitView : NSObject

+ (UIView*)CreateWaitView:(NSString *)waitInfo tag:(NSInteger)tag;

@end


WaitView.m



#import "WaitView.h"

@implementation WaitView

+ (UIView*)CreateWaitView:(NSString *)waitInfo tag:(NSInteger)tag

{

    CGRect waitViewRect = CGRectMake(80, 180-64, 160, 120);//368

    UIView *waitView = [[UIView alloc] initWithFrame:waitViewRect];

    waitView.backgroundColor = [UIColor clearColor];

    CGRect bgImageRect = CGRectZero;

    bgImageRect.size = waitViewRect.size;

    UIImageView *bgImageView = [[UIImageView alloc] initWithFrame:bgImageRect];

    bgImageView.image = [UIImage imageNamed:@"waitBg.png"];

    [bgImageView setAlpha:0.8];

    [waitView addSubview:bgImageView];

    

    CGRect activityViewRect = CGRectMake(55,25, 50, 50);

    UIActivityIndicatorView *activityView= [[UIActivityIndicatorView alloc] initWithFrame:activityViewRect];

    activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;

    [waitView addSubview:activityView];

    

    CGRect labelRect = activityViewRect;

    labelRect.origin.y = activityViewRect.origin.y + activityViewRect.size.height;

    labelRect.origin.x = 0;

    labelRect.size.height = 30;

    labelRect.size.width = waitViewRect.size.width;

    UILabel *label = [[UILabel alloc] initWithFrame:labelRect];

    label.backgroundColor = [UIColor clearColor];

    label.textColor = [UIColor whiteColor];

    label.text = waitInfo;

    label.font = [UIFont systemFontOfSize:14.0];

    label.textAlignment = NSTextAlignmentCenter;

    [waitView addSubview:label];

    

    [activityView startAnimating];

    [waitView setTag:tag];

    return waitView;

}

@end


下面的是其中背景图片的素材。




使用的时候在你想调用的地方:


UIView*waitView=[WaitViewCreateWaitView:@"正在努力加载....." tag:100];

 [self.view addSubview:waitView];


不要忘记导入 :  


#import "WaitView.h"




//****************************************************和上面无关。

- (void)showWaitView:(NSString*)info;

- (void)dismissWaitView;


- (void)showWaitView:(NSString*)info

{

    UIView *waitView = [WaitViewCreateWaitView:info tag:(EFAMILYNUMTAG*2)];

    [self.view addSubview:waitView];

    self.view.userInteractionEnabled =NO;

}


- (void)dismissWaitView

{

    [[self.viewviewWithTag:(EFAMILYNUMTAG*2)]removeFromSuperview];

    self.view.userInteractionEnabled =YES;

}





0 0