exoensiveGifGiftV.m 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // exoensiveGifGiftV.m
  3. // yunbaolive
  4. //
  5. // Created by Boom on 2018/10/16.
  6. // Copyright © 2018年 cat. All rights reserved.
  7. //
  8. #import "exoensiveGifGiftV.h"
  9. #import <YYWebImage/YYWebImage.h>
  10. @implementation exoensiveGifGiftV{
  11. }
  12. -(instancetype)initWithGiftData:(NSDictionary *)giftData andVideoitem:(SVGAVideoEntity * _Nullable)videoitem{
  13. self = [super init];
  14. if (self) {
  15. self.frame = CGRectMake(0, 0, _window_width, _window_height);
  16. [self creatUIWithGiftData:giftData andVideoitem:videoitem];
  17. }
  18. return self;
  19. }
  20. - (void)creatUIWithGiftData:(NSDictionary *)giftData andVideoitem:(SVGAVideoEntity * _Nullable)videoitem{
  21. if (videoitem) {
  22. SVGAPlayer *player = [[SVGAPlayer alloc] initWithFrame:CGRectMake(0, (_window_height-(_window_width/videoitem.videoSize.width*videoitem.videoSize.height))/2, _window_width, (_window_width/videoitem.videoSize.width*videoitem.videoSize.height))];
  23. [self addSubview:player];
  24. player.videoItem = videoitem;
  25. [player startAnimation];
  26. }else{
  27. UIImageView *imgView = [YYAnimatedImageView new];
  28. imgView.frame = CGRectMake(0, 0, _window_width, _window_height);
  29. imgView.yy_imageURL = [NSURL URLWithString:minstr([giftData valueForKey:@"swf"])];
  30. imgView.contentMode = UIViewContentModeScaleAspectFit;
  31. [self addSubview:imgView];
  32. }
  33. CGFloat seconds = [[giftData valueForKey:@"swftime"] floatValue];
  34. NSString *gdy_r_name = minstr([giftData valueForKey:@"giftname"]);
  35. if ([lagType isEqual:EN]) {
  36. gdy_r_name = minstr([giftData valueForKey:@"giftname_en"]);
  37. }
  38. NSString *titleStr = [NSString stringWithFormat:@"%@ %@%@",minstr([giftData valueForKey:@"nickname"]),YZMsg(@"送了一个"),gdy_r_name];
  39. CGFloat titleWidth = [PublicObj sizeWithString:titleStr andFont:SYS_Font(14)].width;
  40. UIImageView *titleBackImgView = [[UIImageView alloc]initWithFrame:CGRectMake(_window_width, 95, 35+titleWidth+20, 30)];//Y:110
  41. titleBackImgView.image = [UIImage imageNamed:@"moviePlay_title"];
  42. titleBackImgView.alpha = 0.5;
  43. titleBackImgView.layer.cornerRadius = 15;
  44. titleBackImgView.layer.masksToBounds = YES;
  45. [self addSubview:titleBackImgView];
  46. UIImageView *laba = [[UIImageView alloc]initWithFrame:CGRectMake(10, 7.5, 15, 15)];
  47. laba.image = [UIImage imageNamed:@"豪华礼物提示.png"];
  48. [titleBackImgView addSubview:laba];
  49. UILabel *titL = [[UILabel alloc]initWithFrame:CGRectMake(laba.right+10, 0, titleWidth+20, 30)];
  50. titL.text = titleStr;
  51. titL.textColor = [UIColor whiteColor];
  52. titL.font = [UIFont systemFontOfSize:14];
  53. [titleBackImgView addSubview:titL];
  54. [UIView animateWithDuration:seconds/4 animations:^{
  55. titleBackImgView.alpha = 1;
  56. titleBackImgView.x = 10;
  57. }];
  58. dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(seconds*0.75 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  59. [UIView animateWithDuration:seconds/4 animations:^{
  60. titleBackImgView.alpha = 0;
  61. titleBackImgView.x = -_window_width;
  62. } completion:^(BOOL finished) {
  63. [titleBackImgView removeFromSuperview];
  64. }];
  65. });
  66. }
  67. - (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
  68. UIView *hitView = [super hitTest:point withEvent:event];
  69. if(hitView == self){
  70. return nil;
  71. }
  72. return hitView;
  73. }
  74. @end