All Products
Search
Document Center

Mobile Platform as a Service:Loading component

Last Updated:Jul 20, 2023

AULoadingView is a new loading control that provides a loading page with progress indicator, loading progress, and loading text.

API description

AULoadingView.h

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

#import <UIKit/UIKit.h>

/**
  Set the middle loading control to display a percentage.
 */
@interface AULoadingView : UIView

@property (nonatomic,assign) BOOL isShowProgressPer; // Specify whether to display the progress percentage. The default value is NO.
@property (nonatomic,assign) BOOL isShowLoadingText; // Specify whether to display the loading text. The default value is NO.


/**
  Set the progress percentage.

 @param progress The percentage.
 */
- (void) setProgressPer:(CGFloat) progress;


@end

Sample code

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