| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // 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()<UITextViewDelegate>
- @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
|