// // JXMoneyShareView.m // shiku_im // // Created by 123 on 2020/6/22. // Copyright © 2020 Reese. All rights reserved. // #import "JXhelpMoneyView.h" @interface JXhelpMoneyView() @property (nonatomic,weak)UILabel *timeStr; @property (nonatomic,weak) JXhelpMoneyView *show; @property (nonatomic,weak) UIImageView *subIMG; @end @implementation JXhelpMoneyView -(instancetype)initWithFrame:(CGRect)frame{ if (self=[super initWithFrame:frame]) { UIView *backView=[[UIView alloc]init]; backView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.3]; [self addSubview:backView]; [backView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(0); make.left.and.right.mas_equalTo(0); make.bottom.mas_equalTo(0); }]; UIImageView *whiteShowView=[[UIImageView alloc]init]; whiteShowView.image=[UIImage imageNamed:@"shareBackIMG"]; whiteShowView.userInteractionEnabled=YES; [backView addSubview:whiteShowView]; [whiteShowView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(backView.mas_centerX); make.centerY.mas_equalTo(backView.mas_centerY); make.left.mas_equalTo(50); make.right.mas_equalTo(-50); }]; // subIMG.image=[UIImage imageNamed:@"尊敬的会员"]; UILabel *subtitle=[[UILabel alloc]init]; subtitle.text=@" 恭喜您,成功领取1888元转运金请到我的账户查看余额,如果长时间未到账请联系在线客服! "; subtitle.textColor=[UIColor whiteColor]; subtitle.numberOfLines=0; subtitle.font=[UIFont systemFontOfSize:13 weight:UIFontWeightMedium]; [whiteShowView addSubview:subtitle]; self.subtitle=subtitle; [subtitle mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(60); make.left.mas_equalTo(1); make.right.mas_equalTo(-1); make.centerX.mas_equalTo(whiteShowView.mas_centerX); }]; //subtitle.hidden=YES; UIButton *tongYiBtn=[[UIButton alloc]init]; tongYiBtn.titleLabel.font=[UIFont systemFontOfSize:11 weight:UIFontWeightMedium]; [tongYiBtn setTitle:@"5秒自动关闭" forState:UIControlStateNormal]; [tongYiBtn setTitleColor:kRGBColor51 forState:UIControlStateNormal]; [whiteShowView addSubview:tongYiBtn]; self.tongYiBtn=tongYiBtn; [tongYiBtn addTarget:self action:@selector(tongyiBtn:) forControlEvents:UIControlEventTouchUpInside]; [tongYiBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(-10); make.centerX.mas_equalTo(whiteShowView.mas_centerX); }]; [self thirdBtnAction]; } return self; } - (void)setStrURL:(NSString *)strURL{ _subtitle.numberOfLines=0; _subtitle.text=[NSString stringWithFormat:@" 恭喜您,成功领取%@元转运金请到我的账户查看余额,如果长时间未到账请联系在线客服! ",strURL]; } - (void)thirdBtnAction { __block NSInteger second = 5; //(1) dispatch_queue_t quene = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); //(2) dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, quene); //(3) dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC, 0 * NSEC_PER_SEC); //(4) dispatch_source_set_event_handler(timer, ^{ dispatch_async(dispatch_get_main_queue(), ^{ if (second == 0) { self.tongYiBtn.userInteractionEnabled = YES; [self.tongYiBtn setTitle:[NSString stringWithFormat:@"5秒自动关闭"] forState:UIControlStateNormal]; // second = 10; //(6) dispatch_cancel(timer); [self removeFromSuperview]; } else { self.tongYiBtn.userInteractionEnabled = NO; [self.tongYiBtn setTitle:[NSString stringWithFormat:@"(%ld)秒自动关闭",(long)second] forState:UIControlStateNormal]; second--; } }); }); //(5) dispatch_resume(timer); } +(void)showView{ JXhelpMoneyView *show=[[JXhelpMoneyView alloc]init]; show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7]; show.frame=[UIScreen mainScreen].bounds; [[UIApplication sharedApplication].keyWindow addSubview:show]; } -(void)dissmisView{ [self removeFromSuperview]; } - (void)tongyiBtn:(UIButton *)sender{ // [g_notify postNotificationName:@"comeBack" object:nil]; // } @end