73 lines
2.3 KiB
Mathematica
73 lines
2.3 KiB
Mathematica
|
|
//
|
||
|
|
// XYloading.m
|
||
|
|
// XiYuanPlus
|
||
|
|
//
|
||
|
|
// Created by lijie lijie on 2018/4/25.
|
||
|
|
// Copyright © 2018年 Hoping. All rights reserved.
|
||
|
|
//
|
||
|
|
|
||
|
|
#import "XYloading.h"
|
||
|
|
|
||
|
|
@implementation XYloading
|
||
|
|
|
||
|
|
|
||
|
|
+ (XYloading *)sharedView {
|
||
|
|
static dispatch_once_t once;
|
||
|
|
static XYloading *sharedView;
|
||
|
|
dispatch_once(&once, ^ { sharedView = [[self alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; });
|
||
|
|
return sharedView;
|
||
|
|
}
|
||
|
|
|
||
|
|
- (instancetype)initWithFrame:(CGRect)frame
|
||
|
|
{
|
||
|
|
self = [super initWithFrame:frame];
|
||
|
|
if (self) {
|
||
|
|
//bgView
|
||
|
|
UIView *bgView = [[UIView alloc] initWithFrame:self.frame];
|
||
|
|
[self addSubview:bgView];
|
||
|
|
//contentView
|
||
|
|
float width = 170;
|
||
|
|
UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
|
||
|
|
contentView.backgroundColor = [UIColor clearColor];
|
||
|
|
contentView.clipsToBounds = YES;
|
||
|
|
contentView.layer.cornerRadius = 6;
|
||
|
|
contentView.center = self.center;
|
||
|
|
[self addSubview:contentView];
|
||
|
|
//showContent
|
||
|
|
UILabel *contentLab = [[UILabel alloc] initWithFrame:CGRectMake(10, 110, width-20, 30)];
|
||
|
|
contentLab.center = self.center;
|
||
|
|
contentLab.tag = 2;
|
||
|
|
contentLab.numberOfLines = 0;
|
||
|
|
contentLab.textColor = [UIColor lightGrayColor];
|
||
|
|
contentLab.font = [UIFont systemFontOfSize:11];
|
||
|
|
contentLab.backgroundColor = [UIColor clearColor];
|
||
|
|
contentLab.textAlignment = NSTextAlignmentCenter;
|
||
|
|
contentLab.text = @"不要着急、稍等一下\n页面使劲请求中...";
|
||
|
|
[contentView addSubview:contentLab];
|
||
|
|
self.tag = -100;
|
||
|
|
}
|
||
|
|
return self;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ (void)showWithStrings:(NSString *)contentStr {
|
||
|
|
[[self sharedView] showContent:contentStr];
|
||
|
|
}
|
||
|
|
|
||
|
|
+ (void)dismiss{
|
||
|
|
[[self sharedView] removeFromSuperview];
|
||
|
|
}
|
||
|
|
|
||
|
|
-(void)showContent:(NSString *)contentStr{
|
||
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||
|
|
UILabel *contentLab = (UILabel *)[self viewWithTag:2];
|
||
|
|
contentLab.text = contentStr;
|
||
|
|
if ([contentStr isEqualToString:@""]) {
|
||
|
|
contentLab.text = @"不要着急、稍等一下\n页面使劲请求中...";
|
||
|
|
}
|
||
|
|
UIWindow *window = [UIApplication sharedApplication].delegate.window;
|
||
|
|
[window addSubview:self];
|
||
|
|
});
|
||
|
|
}
|
||
|
|
|
||
|
|
@end
|