123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- //
- // KSCustomLoadingView.m
- // GuanYueTeamTeacher
- //
- // Created by 王智 on 2023/2/2.
- //
- #import "KSCustomLoadingView.h"
- #import <Lottie/Lottie.h>
- @interface KSCustomLoadingView ()
- @property (weak, nonatomic) IBOutlet UIView *containerView;
- @property (weak, nonatomic) IBOutlet UILabel *text;
- @property (nonatomic, strong) LOTAnimationView *animationView;
- @end
- @implementation KSCustomLoadingView
- + (instancetype)shareInstance {
- KSCustomLoadingView *view = [[[NSBundle mainBundle] loadNibNamed:@"KSCustomLoadingView" owner:nil options:nil] firstObject];
- return view;
- }
- - (void)showLoadingView {
- UIWindow *windows = [NSObject getKeyWindow];
- [windows addSubview:self];
- [self mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.bottom.mas_equalTo(windows);
- }];
- [self.containerView addSubview:self.animationView];
- [self.animationView mas_remakeConstraints:^(MASConstraintMaker *make) {
- make.left.right.top.bottom.mas_equalTo(self.containerView);
- }];
- [self.animationView play];
- }
- - (void)hideLoadingView {
- if (self.animationView.isAnimationPlaying) {
- [self.animationView stop];
- }
- [self removeFromSuperview];
- }
- - (LOTAnimationView *)animationView {
- if (!_animationView) {
- _animationView = [LOTAnimationView animationNamed:@"teacher_refresh"];
- _animationView.contentMode = UIViewContentModeScaleAspectFill;
- _animationView.animationSpeed = 1.0;
- _animationView.loopAnimation = YES;
- }
- return _animationView;
- }
- - (void)setDisplayText:(NSString *)displayText {
- _displayText = displayText;
- self.text.text = displayText;
- }
- /*
- // Only override drawRect: if you perform custom drawing.
- // An empty implementation adversely affects performance during animation.
- - (void)drawRect:(CGRect)rect {
- // Drawing code
- }
- */
- @end
|