|
|
|
@@ -9,6 +9,7 @@
|
|
|
|
|
#import "XCHUDTool.h"
|
|
|
|
|
#import "GCDHelper.h"
|
|
|
|
|
#import <MBProgressHUD/MBProgressHUD.h>
|
|
|
|
|
#import "ThemeColor.h"
|
|
|
|
|
|
|
|
|
|
#define kDelayTime 2.5
|
|
|
|
|
@interface XCHUDTool ()
|
|
|
|
@@ -244,6 +245,21 @@ static NSArray * _animationImages = nil;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ (void)showAnchorLoading {
|
|
|
|
|
UIView *view = [UIApplication sharedApplication].keyWindow;
|
|
|
|
|
dispatch_main_sync_safe(^{
|
|
|
|
|
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
|
|
|
|
|
hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
|
|
|
|
|
hud.userInteractionEnabled = NO;
|
|
|
|
|
hud.mode = MBProgressHUDModeCustomView;
|
|
|
|
|
hud.minSize = CGSizeMake(240, 180 + 16 + 30);
|
|
|
|
|
[hud.bezelView addSubview:[self anchorSwitchLoadingView]];
|
|
|
|
|
hud.bezelView.color = [UIColor clearColor];
|
|
|
|
|
hud.removeFromSuperViewOnHide = YES;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#pragma mark - private
|
|
|
|
|
+ (MBProgressHUD *)normalProgressHUD:(UIView *)view {
|
|
|
|
|
MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:view animated:YES];
|
|
|
|
@@ -300,6 +316,47 @@ static NSArray * _animationImages = nil;
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (UIView *)anchorSwitchLoadingView {
|
|
|
|
|
UIView *loadingBGView = [[UIView alloc] init];
|
|
|
|
|
loadingBGView.layer.cornerRadius = 20;
|
|
|
|
|
loadingBGView.backgroundColor = [UIColor clearColor];
|
|
|
|
|
UIImageView *loadingImageView = [[UIImageView alloc] init];
|
|
|
|
|
|
|
|
|
|
UILabel *loadingTitleLabel = [[UILabel alloc] init];
|
|
|
|
|
loadingTitleLabel = [[UILabel alloc] init];
|
|
|
|
|
loadingTitleLabel.textColor = UIColorFromRGB(0xC9BCF2);
|
|
|
|
|
loadingTitleLabel.font = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
|
|
|
|
|
loadingTitleLabel.text = @"加载中…";
|
|
|
|
|
loadingTitleLabel.textAlignment = NSTextAlignmentCenter;
|
|
|
|
|
|
|
|
|
|
[loadingBGView addSubview:loadingImageView];
|
|
|
|
|
[loadingBGView addSubview:loadingTitleLabel];
|
|
|
|
|
|
|
|
|
|
loadingBGView.frame = CGRectMake(0,0,240,180 + 16 + 30);
|
|
|
|
|
loadingImageView.frame = CGRectMake(0, 0, 240, 180);
|
|
|
|
|
loadingTitleLabel.frame = CGRectMake(0, CGRectGetMaxY(loadingImageView.frame) + 8, loadingBGView.frame.size.width, 15);
|
|
|
|
|
loadingImageView.animationImages = [self loadingAnchorAnimationImages];
|
|
|
|
|
[loadingImageView startAnimating];
|
|
|
|
|
return loadingBGView;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSArray<UIImage *> *)loadingAnchorAnimationImages {
|
|
|
|
|
NSString * countString = @"00";
|
|
|
|
|
NSMutableArray * imageArray= [NSMutableArray array];
|
|
|
|
|
for (int i = 0; i <= 23; i++) {
|
|
|
|
|
if (i < 10) {
|
|
|
|
|
countString = [NSString stringWithFormat:@"0%d", i];
|
|
|
|
|
} else {
|
|
|
|
|
countString = [NSString stringWithFormat:@"%d", i];
|
|
|
|
|
}
|
|
|
|
|
NSString * loadingImageName = [NSString stringWithFormat:@"anchorLoading_0%@", countString];
|
|
|
|
|
UIImage * image = [UIImage imageNamed:loadingImageName];
|
|
|
|
|
[imageArray addObject:image];
|
|
|
|
|
}
|
|
|
|
|
NSArray * array = [imageArray copy];
|
|
|
|
|
return array;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
+ (NSArray *)animationImages {
|
|
|
|
|
if (_animationImages == nil) {
|
|
|
|
|
_animationImages = [NSArray array];
|
|
|
|
|