| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- //
- // JXRegisterShowView.m
- // shiku_im
- //
- // Created by 123 on 2020/5/18.
- // Copyright © 2020 Reese. All rights reserved.
- //
- #import "JXRegisterShowView.h"
- @interface JXRegisterShowView()<UITextViewDelegate>
- @property (nonatomic,weak) JXRegisterShowView *show;
- @property (nonatomic,weak) UILabel *titleL;
- @end
- @implementation JXRegisterShowView
-
- -(instancetype)initWithFrame:(CGRect)frame{
-
- if (self=[super initWithFrame:frame]) {
- self.userInteractionEnabled=YES;
- UIView *backView=[[UIView alloc]init];
- backView.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.3];
- backView.userInteractionEnabled=YES;
- [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);
- }];
-
- UIView *whiteShowView=[[UIView alloc]init];
- whiteShowView.backgroundColor=[UIColor colorWithWhite:1.0 alpha:1.0];
- whiteShowView.layer.cornerRadius=15;
- whiteShowView.layer.masksToBounds=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);
- make.height.mas_equalTo(380);
- }];
-
-
- UILabel *titleL=[[UILabel alloc]init];
- titleL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- titleL.text=@"温馨提示";
- titleL.textAlignment=NSTextAlignmentCenter;
- [whiteShowView addSubview:titleL];
- self.titleL=titleL;
- [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(15);
- make.left.mas_equalTo(30);
- make.right.mas_equalTo(-30);
- }];
-
-
- UITextView *textView=[[UITextView alloc]init];
- textView.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- [whiteShowView addSubview:textView];
- textView.delegate=self;
- textView.selectable=NO;
- self.textView=textView;
- [textView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(titleL.mas_bottom).mas_equalTo(20);
- make.left.mas_equalTo(30);
- make.right.mas_equalTo(-30);
- make.height.mas_equalTo(240);
- }];
-
-
- UIButton *tongYiBtn=[[UIButton alloc]init];
- tongYiBtn.titleLabel.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
- [tongYiBtn setTitle:@"同意" forState:UIControlStateNormal];
- tongYiBtn.backgroundColor=kRGBColor(227, 89, 89);
- tongYiBtn.layer.cornerRadius=6;
- tongYiBtn.layer.masksToBounds=YES;
- [whiteShowView addSubview:tongYiBtn];
- self.tongYiBtn=tongYiBtn;
- [tongYiBtn addTarget:self action:@selector(tongyiBtn:) forControlEvents:UIControlEventTouchUpInside];
- [tongYiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.mas_equalTo(-23);
- make.height.mas_equalTo(38);
- make.width.mas_equalTo(94);
- make.centerX.mas_equalTo(whiteShowView.mas_centerX);
- }];
-
- [self thirdBtnAction];
-
- }
-
- return self;
- }
- - (void)thirdBtnAction {
- __block NSInteger second = 10;
- //(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:@"同意"] forState:UIControlStateNormal];
- second = 10;
- _tongYiBtn.backgroundColor=kRGBColor(227, 89, 89);
- //(6)
- dispatch_cancel(timer);
- } else {
- self.tongYiBtn.userInteractionEnabled = NO;
- [self.tongYiBtn setTitle:[NSString stringWithFormat:@"同意(%ld)",(long)second] forState:UIControlStateNormal];
- _tongYiBtn.backgroundColor=kRGBColor(124, 124, 124);
- second--;
- }
- });
- });
- //(5)
- dispatch_resume(timer);
- }
- - (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
- if ([text isEqualToString:@"\n"]) {
- return NO;
- }
- return YES;
- }
- +(void)showView{
- JXRegisterShowView *show=[[JXRegisterShowView alloc]init];
- show.backgroundColor=[UIColor colorWithWhite:0.0 alpha:0.7];
- show.frame=[UIScreen mainScreen].bounds;
- [[UIApplication sharedApplication].keyWindow addSubview:show];
-
-
- }
- -(void)setDataDict:(NSDictionary *)dataDict{
-
- self.titleL.text=dataDict[@"title"];
- NSString *htmlString =[NSString stringWithFormat:@"%@",dataDict[@"content"]];
- // htmlString = [htmlString stringByReplacingOccurrencesOfString:@"\n" withString:@" "];
-
- NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData: [htmlString dataUsingEncoding:NSUnicodeStringEncoding] options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes: nil error: nil];
-
- self.textView.attributedText = attributedString;
-
- }
- +(void)closeView{
-
- }
- -(void)dissmisView{
-
- [self removeFromSuperview];
-
- }
- - (void)tongyiBtn:(UIButton *)sender{
-
- [self removeFromSuperview];
- }
- @end
|