// // JXMessShowView.m // shiku_im // // Created by 123 on 2020/6/11. // Copyright © 2020 Reese. All rights reserved. // #import "JXMessShowView.h" #import "JXRegisterShowView.h" @interface JXMessShowView() @property (nonatomic,weak)UILabel *timeStr; @property (nonatomic,weak) JXMessShowView *show; @end @implementation JXMessShowView -(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); }]; 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(JX_SCREEN_HEIGHT/2+40); }]; UILabel *titleL=[[UILabel alloc]init]; titleL.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; titleL.text=@"紧急通知"; titleL.textAlignment=NSTextAlignmentCenter; [whiteShowView addSubview: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.editable=NO; textView.delegate=self; self.textView=textView; [textView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(titleL.mas_bottom).mas_equalTo(20); make.left.mas_equalTo(20); make.right.mas_equalTo(-20); make.height.mas_equalTo(JX_SCREEN_HEIGHT/2-95); }]; UILabel *timeStr=[[UILabel alloc]init]; timeStr.font=[UIFont systemFontOfSize:15 weight:UIFontWeightRegular]; timeStr.text=@"2019"; timeStr.textAlignment=NSTextAlignmentRight; [whiteShowView addSubview:timeStr]; self.timeStr=timeStr; [timeStr mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(textView.mas_bottom); make.right.mas_equalTo(-10); make.height.mas_equalTo(18); }]; UIButton *tongYiBtn=[[UIButton alloc]init]; tongYiBtn.titleLabel.font=[UIFont systemFontOfSize:16 weight:UIFontWeightMedium]; [tongYiBtn setTitle:@"知道了" forState:UIControlStateNormal]; [tongYiBtn setTitleColor:kRGBColor51 forState:UIControlStateNormal]; //tongYiBtn.backgroundColor=kRGBColor(227, 89, 89); //tongYiBtn.layer.borderColor=kRGBColor(246, 246, 246).CGColor; //tongYiBtn.layer.borderWidth=0.5; tongYiBtn.layer.cornerRadius=15; tongYiBtn.layer.masksToBounds=YES; [whiteShowView addSubview:tongYiBtn]; [tongYiBtn addTarget:self action:@selector(tongyiBtn:) forControlEvents:UIControlEventTouchUpInside]; [tongYiBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.mas_equalTo(-5); make.height.mas_equalTo(36); make.width.mas_equalTo(94); make.centerX.mas_equalTo(whiteShowView.mas_centerX); }]; } return self; } -(void)setContentDic:(NSDictionary *)contentDic{ NSString *htmlString =[NSString stringWithFormat:@"%@",contentDic[@"content"]]; NSAttributedString *attributedString = [[NSAttributedString alloc] initWithData: [htmlString dataUsingEncoding:NSUnicodeStringEncoding] options: @{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes: nil error: nil]; self.textView.attributedText = attributedString; NSString *timeStr = [self timeFormate:[NSString stringWithFormat:@"%@",contentDic[@"createTime"]]]; self.timeStr.text=timeStr; } - (NSString *)timeFormate:(NSString *)timeS{ NSTimeInterval time=[timeS doubleValue]+28800;//因为时差问题要加8小时 == 28800 sec NSDate *detaildate=[NSDate dateWithTimeIntervalSince1970:time/1000]; //NSLog(@"date:%@",[detaildate description]); //实例化一个NSDateFormatter对象 NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; //设定时间格式,这里可以设置成自己需要的格式 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm"]; NSString *currentDateStr = [dateFormatter stringFromDate: detaildate]; return currentDateStr; } +(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)dissmisView{ [self removeFromSuperview]; } - (void)tongyiBtn:(UIButton *)sender{ [g_notify postNotificationName:@"closeShowxxx" object:nil]; [self removeFromSuperview]; [self removeFromSuperview]; } @end