| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- //
- // MOClickActiveGuideView.m
- // MiMoLive
- //
- // Created by SuperC on 2024/4/23.
- //
- #import "MOClickActiveGuideView.h"
- @interface MOClickActiveGuideView ()<SVGAPlayerDelegate>
- @property (nonatomic, strong) MOSVGACustomPlayer *aPlayer; //引导动画
- @property (nonatomic, strong) SVGAParser *aParser;
- @property (nonatomic, assign) BOOL shouldPlayOnceMore;//需要多播放一次
- @end
- @implementation MOClickActiveGuideView
- + (instancetype)moClickActiveGuideView{
- return [[[NSBundle mainBundle] loadNibNamed:@"MOClickActiveGuideView" owner:self options:nil] firstObject];
- }
- - (void)awakeFromNib{
- [super awakeFromNib];
-
- [self addSubview:self.aPlayer];
- CGFloat width = SCREENWIDTH;
- CGFloat y = SCREENHEIGHT - 500;
- self.aPlayer.frame = CGRectMake(0, y, width, 500);
-
- WEAKSELF
- [self.aParser parseWithNamed:@"icon_guide_click_active" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
- if (videoItem) {
-
- weakSelf.aPlayer.videoItem = videoItem;
- [weakSelf.aPlayer startAnimation];
- }
- } failureBlock:^(NSError * _Nonnull error) {
- MOLogV(@"播放失败~~~~~~~~");
- }];
- }
- - (IBAction)closeBtnClick:(id)sender {
- [self dismissClickActiveGuideView];
- }
- - (void)showClickActiveGuideView//界面显示动画
- {
- UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
- [keyWindow addSubview:self];
- self.frame = CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT);
- }
- - (void)showClickActiveGuideViewInView:(UIView *)superView {
- [superView addSubview:self];
- self.frame = superView.bounds;
- }
- - (void)dismissClickActiveGuideView
- {
- [self removeFromSuperview];
- }
- //延迟一次播放后消失
- - (void)delayToDismiss
- {
- // [self performSelector:@selector(dismissClickActiveGuideView) withObject:nil afterDelay:2.0];
- self.shouldPlayOnceMore = YES;
- }
- /// 动画播放完成(一次循环结束)
- - (void)svgaPlayerDidFinishedAnimation:(SVGAPlayer *)player {
- [self dismissClickActiveGuideView];
- }
- - (void)svgaPlayer:(SVGAPlayer *)player didAnimatedToPercentage:(CGFloat)percentage {
- if (self.shouldPlayOnceMore) {
- if (percentage == 1.0) {
- self.aPlayer.loops = 1;
- [self.aPlayer startAnimation];
- }
- }
- }
- #pragma mark - setter/getter
- - (MOSVGACustomPlayer *)aPlayer {
-
- if (_aPlayer == nil) {
- _aPlayer = [[MOSVGACustomPlayer alloc] init];
- _aPlayer.delegate = self;
- _aPlayer.loops = 0;
- _aPlayer.clearsAfterStop = YES;
- _aPlayer.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _aPlayer;
- }
- - (SVGAParser *)aParser{
-
- if (_aParser == nil) {
- _aParser = [[SVGAParser alloc]init];
- }
-
- return _aParser;
- }
- @end
|