修改登录页SVGA动图

This commit is contained in:
chenshuanglin
2023-03-20 20:49:47 +08:00
parent 5bfb43093c
commit 3358f0c68e
4 changed files with 60 additions and 16 deletions

View File

@@ -9,6 +9,7 @@
/// ///
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h> #import <ReactiveObjC/ReactiveObjC.h>
#import <SVGA.h>
///Tool ///Tool
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "ThemeColor.h" #import "ThemeColor.h"
@@ -35,7 +36,7 @@
@property (nonatomic,strong) UIButton *nextButton; @property (nonatomic,strong) UIButton *nextButton;
/// ///
@property (nonatomic,strong) UIButton *backButton; @property (nonatomic,strong) UIButton *backButton;
@property (nonatomic,strong) UIImageView *logoImageView; @property (nonatomic,strong) SVGAPlayer *logoImageView;
@end @end
@implementation LoginPasswordViewController @implementation LoginPasswordViewController
@@ -53,6 +54,7 @@
[self initSubViews]; [self initSubViews];
[self initSubViewConstraints]; [self initSubViewConstraints];
[self initEvents]; [self initEvents];
[self loginAnimation];
} }
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { - (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
@@ -120,6 +122,18 @@
}] takeUntil:self.rac_willDeallocSignal]; }] takeUntil:self.rac_willDeallocSignal];
} }
- (void)loginAnimation {
SVGAParser *parser = [[SVGAParser alloc] init];
@weakify(self);
[parser parseWithNamed:@"login_logo" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@strongify(self);
if (videoItem != nil) {
self.logoImageView.videoItem = videoItem;
[self.logoImageView startAnimation];
}
} failureBlock:nil];
}
- (void)disMissVC { - (void)disMissVC {
UIViewController *vc = self.presentingViewController; UIViewController *vc = self.presentingViewController;
while (vc.presentingViewController) { while (vc.presentingViewController) {
@@ -245,11 +259,11 @@
return _backButton; return _backButton;
} }
- (UIImageView *)logoImageView { - (SVGAPlayer *)logoImageView {
if (!_logoImageView) { if (!_logoImageView) {
_logoImageView = [[UIImageView alloc] init]; _logoImageView = [[SVGAPlayer alloc] init];
_logoImageView.userInteractionEnabled = YES; _logoImageView.loops = 1;
_logoImageView.image = [UIImage imageNamed:@"login_top_bg"]; _logoImageView.clearsAfterStop = NO;
} }
return _logoImageView; return _logoImageView;
} }

View File

@@ -9,6 +9,7 @@
/// ///
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h> #import <ReactiveObjC/ReactiveObjC.h>
#import <SVGA.h>
///Tool ///Tool
#import "UIImage+Utils.h" #import "UIImage+Utils.h"
#import "ThemeColor.h" #import "ThemeColor.h"
@@ -30,7 +31,7 @@
@property (nonatomic,copy) NSString *phone; @property (nonatomic,copy) NSString *phone;
/// ///
@property (nonatomic,strong) UIButton *backButton; @property (nonatomic,strong) UIButton *backButton;
@property (nonatomic,strong) UIImageView *logoImageView; @property (nonatomic,strong) SVGAPlayer *logoImageView;
@end @end
@implementation LoginPhoneViewController @implementation LoginPhoneViewController
@@ -44,6 +45,7 @@
[self initSubViews]; [self initSubViews];
[self initSubViewConstraints]; [self initSubViewConstraints];
[self initEevents]; [self initEevents];
[self loginAnimation];
} }
#pragma mark - Private Method #pragma mark - Private Method
@@ -95,6 +97,18 @@
}]; }];
} }
- (void)loginAnimation {
SVGAParser *parser = [[SVGAParser alloc] init];
@weakify(self);
[parser parseWithNamed:@"login_logo" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@strongify(self);
if (videoItem != nil) {
self.logoImageView.videoItem = videoItem;
[self.logoImageView startAnimation];
}
} failureBlock:nil];
}
#pragma mark - Event Response #pragma mark - Event Response
- (void)nextButtonAction:(UIButton *)sender { - (void)nextButtonAction:(UIButton *)sender {
LoginVerifCodeViewController * codeVC = [[LoginVerifCodeViewController alloc] init]; LoginVerifCodeViewController * codeVC = [[LoginVerifCodeViewController alloc] init];
@@ -164,11 +178,11 @@
return _backButton; return _backButton;
} }
- (UIImageView *)logoImageView { - (SVGAPlayer *)logoImageView {
if (!_logoImageView) { if (!_logoImageView) {
_logoImageView = [[UIImageView alloc] init]; _logoImageView = [[SVGAPlayer alloc] init];
_logoImageView.userInteractionEnabled = YES; _logoImageView.loops = 1;
_logoImageView.image = [UIImage imageNamed:@"login_top_bg"]; _logoImageView.clearsAfterStop = NO;
} }
return _logoImageView; return _logoImageView;
} }

View File

@@ -9,6 +9,7 @@
/// ///
#import <Masonry/Masonry.h> #import <Masonry/Masonry.h>
#import <ReactiveObjC/ReactiveObjC.h> #import <ReactiveObjC/ReactiveObjC.h>
#import <SVGA.h>
///Tool ///Tool
#import "ThemeColor.h" #import "ThemeColor.h"
#import "XPMacro.h" #import "XPMacro.h"
@@ -22,7 +23,7 @@
@interface LoginVerifCodeViewController ()<LoginVerifCodeProtocol> @interface LoginVerifCodeViewController ()<LoginVerifCodeProtocol>
/// ///
@property (nonatomic,strong) UIImageView *backImageView; @property (nonatomic,strong) SVGAPlayer *backImageView;
/// ///
@property (nonatomic,strong) UILabel *titleLabel; @property (nonatomic,strong) UILabel *titleLabel;
/// ///
@@ -120,6 +121,18 @@
} }
- (void)loginAnimation {
SVGAParser *parser = [[SVGAParser alloc] init];
@weakify(self);
[parser parseWithNamed:@"login_logo" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@strongify(self);
if (videoItem != nil) {
self.backImageView.videoItem = videoItem;
[self.backImageView startAnimation];
}
} failureBlock:nil];
}
- (void)httpRequestPhoneSmsCode { - (void)httpRequestPhoneSmsCode {
[self.presenter phoneSmsCode:self.phone type:GetSmsType_Regist]; [self.presenter phoneSmsCode:self.phone type:GetSmsType_Regist];
} }
@@ -227,12 +240,11 @@
} }
} }
#pragma mark - Getters And Setters #pragma mark - Getters And Setters
- (UIImageView *)backImageView { - (SVGAPlayer *)backImageView {
if (!_backImageView) { if (!_backImageView) {
_backImageView = [[UIImageView alloc] init]; _backImageView = [[SVGAPlayer alloc] init];
_backImageView.userInteractionEnabled = YES; _backImageView.loops = 1;
_backImageView.image = [UIImage imageNamed:@"login_top_bg"]; _backImageView.clearsAfterStop = NO;
_backImageView.backgroundColor = [UIColor greenColor];
} }
return _backImageView; return _backImageView;
} }

View File

@@ -176,7 +176,9 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
- (void)loginAnimation { - (void)loginAnimation {
SVGAParser *parser = [[SVGAParser alloc] init]; SVGAParser *parser = [[SVGAParser alloc] init];
@weakify(self);
[parser parseWithNamed:@"login_logo" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) { [parser parseWithNamed:@"login_logo" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
@strongify(self);
if (videoItem != nil) { if (videoItem != nil) {
self.logoImageView.videoItem = videoItem; self.logoImageView.videoItem = videoItem;
[self.logoImageView startAnimation]; [self.logoImageView startAnimation];
@@ -567,6 +569,8 @@ typedef NS_ENUM(NSUInteger, XYLoginType) {
- (SVGAPlayer *)logoImageView { - (SVGAPlayer *)logoImageView {
if (!_logoImageView) { if (!_logoImageView) {
_logoImageView = [[SVGAPlayer alloc] init]; _logoImageView = [[SVGAPlayer alloc] init];
_logoImageView.loops = 1;
_logoImageView.clearsAfterStop = NO;
} }
return _logoImageView; return _logoImageView;
} }