全部产品
云市场
云游戏

加载组件

更新时间:2019-09-26 18:39:58

AULoadingView 为新增的加载控件。

效果图

接口定义

AULoadingView.h

  1. //
  2. // AULoadingView.h
  3. // AntUI
  4. //
  5. #import <UIKit/UIKit.h>
  6. /**
  7. 中间加载的 loading 控件中间含数字
  8. */
  9. @interface AULoadingView : UIView
  10. @property (nonatomic,assign) BOOL isShowProgressPer; //是否显示进度百分比,默认为 NO
  11. @property (nonatomic,assign) BOOL isShowLoadingText; //是否显示加载文案,默认为 NO
  12. /**
  13. 设置进度百分比
  14. @param progress 百分比的值
  15. */
  16. - (void) setProgressPer:(CGFloat) progress;
  17. @end

代码示例

  1. //
  2. // AULoadingViewController.m
  3. // AntUI
  4. //
  5. #import "AULoadingViewController.h"
  6. #import "AULoadingView.h"
  7. @interface AULoadingViewController ()
  8. @property (nonatomic,strong) AULoadingView * loadingView;
  9. @property (nonatomic,strong) AULoadingView * loadingView2;
  10. @property (nonatomic,strong) AULoadingView * loadingView3;
  11. @property (nonatomic,assign) CGFloat progress;
  12. @end
  13. @implementation AULoadingViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. self.view.backgroundColor = [UIColor whiteColor];
  17. // Do any additional setup after loading the view.
  18. self.loadingView = [[AULoadingView alloc] init];
  19. self.loadingView.center = CGPointMake(200, 200);
  20. self.loadingView.isShowProgressPer = YES;
  21. self.loadingView.isShowLoadingText = YES;
  22. [self.view addSubview:self.loadingView];
  23. self.loadingView2 = [[AULoadingView alloc] init];
  24. self.loadingView2.center = CGPointMake(200, 150);
  25. // self.loadingView2.isShowProgressPer = YES;
  26. // self.loadingView2.isShowLoadingText = YES;
  27. [self.view addSubview:self.loadingView2];
  28. self.loadingView3 = [[AULoadingView alloc] init];
  29. self.loadingView3.center = CGPointMake(200, 300);
  30. // self.loadingView3.isShowProgressPer = YES;
  31. self.loadingView3.isShowLoadingText = YES;
  32. [self.view addSubview:self.loadingView3];
  33. [NSTimer scheduledTimerWithTimeInterval:0.1
  34. target:self
  35. selector:@selector(loadingTimer:)
  36. userInfo:nil
  37. repeats:YES];
  38. }
  39. - (void) loadingTimer:(id)timer
  40. {
  41. self.progress += 0.01;
  42. if ((int)(self.progress *100) > 100) {
  43. self.progress = 0.0;
  44. [timer invalidate];
  45. return;
  46. }
  47. [self.loadingView setProgressPer:self.progress];
  48. [self.loadingView2 setProgressPer:self.progress];
  49. [self.loadingView3 setProgressPer:self.progress];
  50. }
  51. - (void)didReceiveMemoryWarning {
  52. [super didReceiveMemoryWarning];
  53. // Dispose of any resources that can be recreated.
  54. }
  55. /*
  56. #pragma mark - Navigation
  57. // In a storyboard-based application, you will often want to do a little preparation before navigation
  58. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  59. // Get the new view controller using [segue destinationViewController].
  60. // Pass the selected object to the new view controller.
  61. }
  62. */
  63. @end