123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- //
- // JXMoneyShareView.m
- // shiku_im
- //
- // Created by 123 on 2020/6/22.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXALLShowView.h"
-
- @interface JXALLShowView()<UITextViewDelegate>
- @property (nonatomic,weak)UILabel *subtitle;
- @property (nonatomic,weak) JXALLShowView *show;
- @end
- @implementation JXALLShowView
-
- -(instancetype)initWithFrame:(CGRect)frame{
-
- if (self=[super initWithFrame:frame]) {
-
- UIView *backView=[[UIView alloc]init];
- backView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.2];
- [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.width.mas_equalTo(JX_SCREEN_WIDTH-100);
- }];
-
-
-
-
- UILabel *subtitle=[[UILabel alloc]init];
- subtitle.text=@"本活动奖励仅限每周六中午12点开放领取!";
- subtitle.textColor=[UIColor whiteColor];
- subtitle.textAlignment=NSTextAlignmentCenter;
- subtitle.numberOfLines=3;
- subtitle.font=[UIFont systemFontOfSize:13 weight:UIFontWeightMedium];
- [whiteShowView addSubview:subtitle];
- self.subtitle=subtitle;
- [subtitle mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(63);
- make.centerX.mas_equalTo(whiteShowView.mas_centerX);
- make.left.mas_equalTo(1);
- make.right.mas_equalTo(-1);
- }];
-
-
- 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(-3);
- make.centerX.mas_equalTo(whiteShowView.mas_centerX);
- }];
-
- [self thirdBtnAction];
- }
-
- return self;
- }
- - (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{
- JXALLShowView *show=[[JXALLShowView alloc]init];
- show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.2];
- show.frame=[UIScreen mainScreen].bounds;
- [[UIApplication sharedApplication].keyWindow addSubview:show];
-
-
- }
- -(void)setNameStr:(NSString *)nameStr{
-
- self.subtitle.text=nameStr.length>0?nameStr:@"本活动奖励仅限每周六中午12点开放领取!";
- }
-
- -(void)dissmisView{
-
- [self removeFromSuperview];
-
- }
- - (void)tongyiBtn:(UIButton *)sender{
-
- // [g_notify postNotificationName:@"comeBack" object:nil];
- //
- }
- @end
|