JXBigReelView.m 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. //
  2. // JXMoneyShareView.m
  3. // shiku_im
  4. //
  5. // Created by 123 on 2020/6/22.
  6. // Copyright © 2020 Reese. All rights reserved.
  7. //
  8. #import "JXBigReelView.h"
  9. @interface JXBigReelView()<UITextViewDelegate>
  10. @property (nonatomic,weak)UILabel *timeStr;
  11. @property (nonatomic,weak) JXBigReelView *show;
  12. @property (nonatomic,weak) UIImageView *subIMG;
  13. @end
  14. @implementation JXBigReelView
  15. -(instancetype)initWithFrame:(CGRect)frame{
  16. if (self=[super initWithFrame:frame]) {
  17. UIView *backView=[[UIView alloc]init];
  18. backView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.3];
  19. [self addSubview:backView];
  20. [backView mas_makeConstraints:^(MASConstraintMaker *make) {
  21. make.top.mas_equalTo(0);
  22. make.left.and.right.mas_equalTo(0);
  23. make.bottom.mas_equalTo(0);
  24. }];
  25. UIImageView *whiteShowView=[[UIImageView alloc]init];
  26. whiteShowView.image=[UIImage imageNamed:@"中奖底板"];
  27. whiteShowView.userInteractionEnabled=YES;
  28. [backView addSubview:whiteShowView];
  29. [whiteShowView mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.centerX.mas_equalTo(backView.mas_centerX);
  31. make.centerY.mas_equalTo(backView.mas_centerY);
  32. //make.left.mas_equalTo(50);
  33. // make.right.mas_equalTo(-50);
  34. //make.height.mas_equalTo(JX_SCREEN_HEIGHT/3);
  35. }];
  36. UIImageView *gongXi=[[UIImageView alloc]init];
  37. gongXi.image=[UIImage imageNamed:@"恭喜您"];
  38. gongXi.userInteractionEnabled=YES;
  39. [whiteShowView addSubview:gongXi];
  40. [gongXi mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.centerY.mas_equalTo(whiteShowView.mas_centerY).mas_offset(8);
  42. make.centerX.mas_equalTo(whiteShowView.mas_centerX);
  43. }];
  44. UIImageView *titleIMG=[[UIImageView alloc]init];
  45. titleIMG.image=[UIImage imageNamed:@"抽中"];
  46. [whiteShowView addSubview:titleIMG];
  47. [titleIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.mas_equalTo(25);
  49. make.top.mas_equalTo(gongXi.mas_bottom).mas_equalTo(8);
  50. }];
  51. UILabel *subtitle=[[UILabel alloc]init];
  52. subtitle.text=@"1";
  53. subtitle.textColor=[UIColor yellowColor];
  54. subtitle.font=[UIFont systemFontOfSize:20 weight:UIFontWeightMedium];
  55. [whiteShowView addSubview:subtitle];
  56. self.subtitle=subtitle;
  57. [subtitle mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.mas_equalTo(titleIMG.mas_right).mas_equalTo(8);
  59. make.centerY.mas_equalTo(titleIMG.mas_centerY);
  60. }];
  61. UIImageView *leveleIMG=[[UIImageView alloc]init];
  62. leveleIMG.image=[UIImage imageNamed:@"等奖拷贝"];
  63. leveleIMG.userInteractionEnabled=YES;
  64. [whiteShowView addSubview:leveleIMG];
  65. [leveleIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  66. make.left.mas_equalTo(subtitle.mas_right).mas_equalTo(8);
  67. make.centerY.mas_equalTo(subtitle.mas_centerY);
  68. }];
  69. UILabel *moneyTitle=[[UILabel alloc]init];
  70. moneyTitle.text=@"888";
  71. moneyTitle.textColor=[UIColor yellowColor];
  72. moneyTitle.font=[UIFont systemFontOfSize:36 weight:UIFontWeightMedium];
  73. [whiteShowView addSubview:moneyTitle];
  74. self.moneyTitle=moneyTitle;
  75. [moneyTitle mas_makeConstraints:^(MASConstraintMaker *make) {
  76. make.left.mas_equalTo(leveleIMG.mas_right).mas_equalTo(8);
  77. make.centerY.mas_equalTo(subtitle.mas_centerY);
  78. }];
  79. UIImageView *yuanIMG=[[UIImageView alloc]init];
  80. yuanIMG.image=[UIImage imageNamed:@"元"];
  81. [whiteShowView addSubview:yuanIMG];
  82. [yuanIMG mas_makeConstraints:^(MASConstraintMaker *make) {
  83. make.left.mas_equalTo(moneyTitle.mas_right).mas_equalTo(8);
  84. make.centerY.mas_equalTo(subtitle.mas_centerY);
  85. }];
  86. UIImageView *titleLL=[[UIImageView alloc]init];
  87. titleLL.image=[UIImage imageNamed:@"fenshaTitle"];
  88. titleLL.userInteractionEnabled=YES;
  89. [whiteShowView addSubview:titleLL];
  90. [titleLL mas_makeConstraints:^(MASConstraintMaker *make) {
  91. make.top.mas_equalTo(moneyTitle.mas_bottom).mas_equalTo(5);
  92. make.centerX.mas_equalTo(whiteShowView.mas_centerX);
  93. }];
  94. UIButton *tongYiBtn=[[UIButton alloc]init];
  95. tongYiBtn.titleLabel.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
  96. [tongYiBtn setImage:[UIImage imageNamed:@"zyjShare"] forState:UIControlStateNormal];
  97. tongYiBtn.layer.cornerRadius=6;
  98. tongYiBtn.layer.masksToBounds=YES;
  99. [whiteShowView addSubview:tongYiBtn];
  100. [tongYiBtn addTarget:self action:@selector(tongyiBtn:) forControlEvents:UIControlEventTouchUpInside];
  101. [tongYiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  102. make.bottom.mas_equalTo(-10);
  103. make.centerX.mas_equalTo(whiteShowView.mas_centerX);
  104. }];
  105. // [self thirdBtnAction];
  106. }
  107. return self;
  108. }
  109. - (void)setStrURL:(NSDictionary *)strURL{
  110. NSString *rewardCode=[NSString stringWithFormat:@"%@",strURL[@"rewardCode"]];;
  111. NSString *moneyLL=[NSString stringWithFormat:@"%@",strURL[@"money"]];
  112. _subtitle.text = rewardCode;
  113. _moneyTitle.text = moneyLL;
  114. }
  115. - (void)thirdBtnAction {
  116. __block NSInteger second = 5;
  117. //(1)
  118. dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  119. //(2)
  120. dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, quene);
  121. //(3)
  122. dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
  123. //(4)
  124. dispatch_source_set_event_handler(timer, ^{
  125. dispatch_async(dispatch_get_main_queue(), ^{
  126. if (second == 0) {
  127. self.tongYiBtn.userInteractionEnabled = YES;
  128. [self.tongYiBtn setTitle:[NSString stringWithFormat:@"5秒自动关闭"] forState:UIControlStateNormal];
  129. // second = 10;
  130. //(6)
  131. dispatch_cancel(timer);
  132. [self removeFromSuperview];
  133. } else {
  134. self.tongYiBtn.userInteractionEnabled = NO;
  135. [self.tongYiBtn setTitle:[NSString stringWithFormat:@"(%ld)秒自动关闭",(long)second] forState:UIControlStateNormal];
  136. second--;
  137. }
  138. });
  139. });
  140. //(5)
  141. dispatch_resume(timer);
  142. }
  143. +(void)showView{
  144. JXBigReelView *show=[[JXBigReelView alloc]init];
  145. show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7];
  146. show.frame=[UIScreen mainScreen].bounds;
  147. [[UIApplication sharedApplication].keyWindow addSubview:show];
  148. }
  149. -(void)dissmisView{
  150. [self removeFromSuperview];
  151. }
  152. - (void)tongyiBtn:(UIButton *)sender{
  153. [self removeFromSuperview];
  154. [g_notify postNotificationName:@"comeBackxxx" object:nil];
  155. //
  156. }
  157. @end