Files
yinmeng-ios/xplan-ios/Main/Message/View/Session/SessionRiskView.m
2022-08-11 16:43:37 +08:00

89 lines
2.3 KiB
Objective-C

//
// SessionRiskView.m
// xplan-ios
//
// Created by 冯硕 on 2022/8/11.
//
#import "SessionRiskView.h"
///Third
#import <Masonry/Masonry.h>
///Tool
#import "ThemeColor.h"
#import "SessionRiskCache.h"
#import "UIButton+EnlargeTouchArea.h"
@interface SessionRiskView ()
@property (strong, nonatomic) UILabel *warnTextLabel;
@property (strong, nonatomic) UIButton *closeButton;
@end
@implementation SessionRiskView
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self initSubViews];
[self initSubViewConstraints];
}
return self;
}
#pragma mark - Private Method
- (void)initSubViews {
self.backgroundColor = UIColorRGBAlpha(0xfee4e4, 1);
[self addSubview:self.warnTextLabel];
[self addSubview:self.closeButton];
}
- (void)initSubViewConstraints {
[self.warnTextLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.mas_equalTo(self.mas_centerX);
make.centerY.mas_equalTo(self.mas_centerY);
}];
[self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
make.width.height.mas_equalTo(8);
make.trailing.mas_equalTo(self.mas_trailing).offset(-15);
make.centerY.mas_equalTo(self.mas_centerY);
}];
}
#pragma mark - Event Response
- (void)closeButtonAction:(UIButton *)sender {
if (self.delegate && [self.delegate respondsToSelector:@selector(sessionRiskViewCloseButtonClick:)]) {
[self.delegate sessionRiskViewCloseButtonClick:self];
}
}
#pragma mark - Getters And Setters
- (void)setWarning:(NSString *)warning {
_warning = warning;
if (_warning) {
self.warnTextLabel.text = _warning;
}
}
- (UILabel *)warnTextLabel {
if (!_warnTextLabel) {
_warnTextLabel = [[UILabel alloc]init];
_warnTextLabel.text = @"温馨提示:对方和您非好友关系,请注意隐私安全!";
_warnTextLabel.textColor = UIColorFromRGB(0xFF5858);
_warnTextLabel.font = [UIFont systemFontOfSize:12.f];
}
return _warnTextLabel;
}
- (UIButton *)closeButton {
if (!_closeButton) {
_closeButton = [[UIButton alloc]init];
[_closeButton setImage:[UIImage imageNamed:@"session_warn_close"] forState:UIControlStateNormal];
[_closeButton setEnlargeEdgeWithTop:10 right:10 bottom:10 left:10];
[_closeButton addTarget:self action:@selector(closeButtonAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _closeButton;
}
@end