加载组件

AULoadingView 为新增的加载控件,提供包含进度图案、加载进度、加载中文案等的加载页。

效果图

接口定义

AULoadingView.h

//
//  AULoadingView.h
//  AntUI
//

#import <UIKit/UIKit.h>

/**
  中间加载的 loading 控件中间含数字
 */
@interface AULoadingView : UIView

@property (nonatomic,assign) BOOL isShowProgressPer; //是否显示进度百分比,默认为 NO
@property (nonatomic,assign) BOOL isShowLoadingText; //是否显示加载文案,默认为 NO


/**
  设置进度百分比

 @param progress 百分比的值
 */
- (void) setProgressPer:(CGFloat) progress;


@end

代码示例

//
//  AULoadingViewController.m
//  AntUI
//

#import "AULoadingViewController.h"
#import "AULoadingView.h"

@interface AULoadingViewController ()
@property (nonatomic,strong) AULoadingView * loadingView;
@property (nonatomic,strong) AULoadingView * loadingView2;
@property (nonatomic,strong) AULoadingView * loadingView3;

@property (nonatomic,assign) CGFloat progress;

@end

@implementation AULoadingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    self.loadingView = [[AULoadingView alloc] init];
    self.loadingView.center = CGPointMake(200, 200);
    self.loadingView.isShowProgressPer = YES;
    self.loadingView.isShowLoadingText = YES;
    [self.view addSubview:self.loadingView];

    self.loadingView2 = [[AULoadingView alloc] init];
    self.loadingView2.center = CGPointMake(200, 150);
//    self.loadingView2.isShowProgressPer = YES;
//    self.loadingView2.isShowLoadingText = YES;
    [self.view addSubview:self.loadingView2];


    self.loadingView3 = [[AULoadingView alloc] init];
    self.loadingView3.center = CGPointMake(200, 300);
//    self.loadingView3.isShowProgressPer = YES;
    self.loadingView3.isShowLoadingText = YES;
    [self.view addSubview:self.loadingView3];


    [NSTimer scheduledTimerWithTimeInterval:0.1
                                                       target:self
                                                     selector:@selector(loadingTimer:)
                                                     userInfo:nil
                                                      repeats:YES];

}


- (void) loadingTimer:(id)timer
{
    self.progress += 0.01;
    if ((int)(self.progress *100) > 100) {
        self.progress = 0.0;
        [timer invalidate];
        return;
    }
    [self.loadingView setProgressPer:self.progress];
    [self.loadingView2 setProgressPer:self.progress];
    [self.loadingView3 setProgressPer:self.progress];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end