JXhelpMoneyView.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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 "JXhelpMoneyView.h"
  9. @interface JXhelpMoneyView()<UITextViewDelegate>
  10. @property (nonatomic,weak)UILabel *timeStr;
  11. @property (nonatomic,weak) JXhelpMoneyView *show;
  12. @property (nonatomic,weak) UIImageView *subIMG;
  13. @end
  14. @implementation JXhelpMoneyView
  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:@"shareBackIMG"];
  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. }];
  35. // subIMG.image=[UIImage imageNamed:@"尊敬的会员"];
  36. UILabel *subtitle=[[UILabel alloc]init];
  37. subtitle.text=@" 恭喜您,成功领取1888元转运金请到我的账户查看余额,如果长时间未到账请联系在线客服! ";
  38. subtitle.textColor=[UIColor whiteColor];
  39. subtitle.numberOfLines=0;
  40. subtitle.font=[UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
  41. [whiteShowView addSubview:subtitle];
  42. self.subtitle=subtitle;
  43. [subtitle mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.top.mas_equalTo(60);
  45. make.left.mas_equalTo(1);
  46. make.right.mas_equalTo(-1);
  47. make.centerX.mas_equalTo(whiteShowView.mas_centerX);
  48. }];
  49. //subtitle.hidden=YES;
  50. UIButton *tongYiBtn=[[UIButton alloc]init];
  51. tongYiBtn.titleLabel.font=[UIFont systemFontOfSize:11 weight:UIFontWeightMedium];
  52. [tongYiBtn setTitle:@"5秒自动关闭" forState:UIControlStateNormal];
  53. [tongYiBtn setTitleColor:kRGBColor51 forState:UIControlStateNormal];
  54. [whiteShowView addSubview:tongYiBtn];
  55. self.tongYiBtn=tongYiBtn;
  56. [tongYiBtn addTarget:self action:@selector(tongyiBtn:) forControlEvents:UIControlEventTouchUpInside];
  57. [tongYiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.bottom.mas_equalTo(-10);
  59. make.centerX.mas_equalTo(whiteShowView.mas_centerX);
  60. }];
  61. [self thirdBtnAction];
  62. }
  63. return self;
  64. }
  65. - (void)setStrURL:(NSString *)strURL{
  66. _subtitle.numberOfLines=0;
  67. _subtitle.text=[NSString stringWithFormat:@" 恭喜您,成功领取%@元转运金请到我的账户查看余额,如果长时间未到账请联系在线客服! ",strURL];
  68. }
  69. - (void)thirdBtnAction {
  70. __block NSInteger second = 5;
  71. //(1)
  72. dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
  73. //(2)
  74. dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, quene);
  75. //(3)
  76. dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
  77. //(4)
  78. dispatch_source_set_event_handler(timer, ^{
  79. dispatch_async(dispatch_get_main_queue(), ^{
  80. if (second == 0) {
  81. self.tongYiBtn.userInteractionEnabled = YES;
  82. [self.tongYiBtn setTitle:[NSString stringWithFormat:@"5秒自动关闭"] forState:UIControlStateNormal];
  83. // second = 10;
  84. //(6)
  85. dispatch_cancel(timer);
  86. [self removeFromSuperview];
  87. } else {
  88. self.tongYiBtn.userInteractionEnabled = NO;
  89. [self.tongYiBtn setTitle:[NSString stringWithFormat:@"(%ld)秒自动关闭",(long)second] forState:UIControlStateNormal];
  90. second--;
  91. }
  92. });
  93. });
  94. //(5)
  95. dispatch_resume(timer);
  96. }
  97. +(void)showView{
  98. JXhelpMoneyView *show=[[JXhelpMoneyView alloc]init];
  99. show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7];
  100. show.frame=[UIScreen mainScreen].bounds;
  101. [[UIApplication sharedApplication].keyWindow addSubview:show];
  102. }
  103. -(void)dissmisView{
  104. [self removeFromSuperview];
  105. }
  106. - (void)tongyiBtn:(UIButton *)sender{
  107. // [g_notify postNotificationName:@"comeBack" object:nil];
  108. //
  109. }
  110. @end