MOGetShowView.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. //
  2. // MOGetShowView.m
  3. // MiMoLive
  4. //
  5. // Created by SuperC on 2024/1/3.
  6. //
  7. #import "MOGetShowView.h"
  8. #import "MOSvgaManager.h"
  9. @interface MOGetShowView ()
  10. @property (nonatomic, strong) MOSVGACustomPlayer *aPlayer; //Tag 礼物:0 座驾:1 用于区分
  11. @property (nonatomic, strong) SVGAParser *aParser;
  12. @end
  13. @implementation MOGetShowView
  14. + (instancetype)moGetShowView{
  15. return [[[NSBundle mainBundle] loadNibNamed:@"MOGetShowView" owner:self options:nil] firstObject];
  16. }
  17. - (void)awakeFromNib{
  18. [super awakeFromNib];
  19. self.sureBtn.layer.cornerRadius = 62.0 / 2.0;
  20. self.sureBtn.layer.masksToBounds = YES;
  21. NSArray *colorArr = @[[MOTools colorWithHexString:@"#6DCDFF" alpha:1.0],[MOTools colorWithHexString:@"#D394FF" alpha:1.0]];
  22. UIImage *image = [MOTools createGradientRectImageWithBounds:CGRectMake(0, 0, 200, 62.0) Colors:colorArr GradientType:0];
  23. [self.sureBtn setBackgroundImage:image forState:UIControlStateNormal];
  24. [self.sureBtn setFont:[MOTextTools getTheFontWithSize:24.0 AndFontName:kNormalContentFontStr]];
  25. [self.levelLab setFont:[MOTextTools getTheFontWithSize:22.0 AndFontName:kNormalContentFontStr]];
  26. // [self insertSubview:self.aPlayer belowSubview:self.iconImgView];
  27. // CGFloat width = SCREENWIDTH;
  28. // CGFloat y = (SCREENHEIGHT - width) / 2.0 - 30.0;
  29. // self.aPlayer.frame = CGRectMake(0.0, y, width, width);
  30. // self.aPlayer.loops = 0;
  31. // self.aPlayer.clearsAfterStop = NO;
  32. //
  33. // WEAKSELF
  34. // [self.aParser parseWithNamed:@"" inBundle:nil completionBlock:^(SVGAVideoEntity * _Nonnull videoItem) {
  35. // if (videoItem) {
  36. //
  37. // weakSelf.aPlayer.videoItem = videoItem;
  38. // [weakSelf.aPlayer startAnimation];
  39. // }
  40. // } failureBlock:^(NSError * _Nonnull error) {
  41. // MOLogV(@"播放失败~~~~~~~~");
  42. // }];
  43. }
  44. - (IBAction)sureBtnClick:(id)sender {
  45. //Ack上报
  46. if(self.viewModel){
  47. [self theEventAck];
  48. }
  49. //隐藏
  50. [self dismissGetShowView];
  51. }
  52. - (void)theEventAck{
  53. [kHttpManager theUserEventAckWithParams:nil andBlock:^(id _Nonnull data, NSError * _Nonnull error) {
  54. if(kCode_Success){
  55. MOLogV(@"%@",[[NSString alloc] initWithData:[NSJSONSerialization dataWithJSONObject:data options:0 error:nil] encoding:NSUTF8StringEncoding]);
  56. }
  57. else{
  58. MOLogV(@"theEventAck 接口报错了");
  59. }
  60. }];
  61. }
  62. - (void)setViewModel:(MOEventList *)viewModel{
  63. _viewModel = viewModel;
  64. if(viewModel.type == 1){
  65. self.viewType = 1;
  66. self.levelLab.text = [NSString stringWithFormat:@"Lv.%.f",viewModel.level];
  67. }
  68. else{
  69. self.viewType = 2;
  70. }
  71. }
  72. - (void)setViewType:(NSInteger)viewType{
  73. _viewType = viewType;
  74. if(viewType == 1){
  75. self.levelLab.hidden = NO;
  76. }
  77. else{
  78. self.levelLab.hidden = YES;
  79. }
  80. }
  81. - (void)showGetShowView//界面显示动画
  82. {
  83. UIWindow *keyWindow = [[UIApplication sharedApplication] delegate].window;
  84. [keyWindow addSubview:self];
  85. self.frame = CGRectMake(0.0, 0.0, SCREENWIDTH, SCREENHEIGHT);
  86. //动画效果
  87. self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
  88. self.bgView.alpha = 0;
  89. [UIView animateWithDuration:0.2 animations:^
  90. {
  91. self.bgView.transform = CGAffineTransformMakeScale(1.0, 1.0);
  92. self.bgView.alpha = 1;
  93. } completion:^(BOOL finished)
  94. {
  95. if(self.isVipGetView){
  96. return;
  97. }
  98. CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.y"];
  99. // 设置动画属性
  100. rotationAnimation.fromValue = @(0);
  101. rotationAnimation.toValue = @(M_PI * 2); // 一圈的弧度
  102. rotationAnimation.duration = 1.5; // 动画持续时间
  103. rotationAnimation.repeatCount = 1; // 重复执行2次
  104. // 添加动画到图层
  105. [self.bgView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
  106. [self.bgView.layer addSublayer:self.iconImgView.layer];
  107. [self.bgView.layer addSublayer:self.levelLab.layer];
  108. }];
  109. }
  110. - (void)dismissGetShowView
  111. {
  112. [UIView animateWithDuration:0.2 animations:^
  113. {
  114. self.bgView.transform = CGAffineTransformMakeScale(1.3, 1.3);
  115. self.bgView.alpha = 0;
  116. } completion:^(BOOL finished)
  117. {
  118. if (finished)
  119. {
  120. [self removeFromSuperview];
  121. }
  122. }];
  123. }
  124. #pragma mark - setter/getter
  125. - (MOSVGACustomPlayer *)aPlayer {
  126. if (_aPlayer == nil) {
  127. _aPlayer = [[MOSVGACustomPlayer alloc] init];
  128. _aPlayer.delegate = self;
  129. _aPlayer.contentMode = UIViewContentModeScaleAspectFill;
  130. }
  131. return _aPlayer;
  132. }
  133. - (SVGAParser *)aParser{
  134. if (_aParser == nil) {
  135. _aParser = [[SVGAParser alloc]init];
  136. }
  137. return _aParser;
  138. }
  139. @end