221 lines
7.9 KiB
Objective-C
221 lines
7.9 KiB
Objective-C
//
|
|
// XPPrivilegeCardConfirmView.m
|
|
// xplan-ios
|
|
//
|
|
// Created by duoban on 2023/7/24.
|
|
//
|
|
|
|
#import "XPPrivilegeCardConfirmView.h"
|
|
@interface XPPrivilegeCardConfirmView()
|
|
@property(nonatomic,strong) UIView *bgView;
|
|
@property(nonatomic,strong) UILabel *titleView;
|
|
@property(nonatomic,strong) UILabel *contentView;
|
|
///取消
|
|
@property(nonatomic,strong) UIButton *cancelBtn;
|
|
///确认
|
|
@property(nonatomic,strong) UIButton *verifyBtn;
|
|
@property(nonatomic,assign) BOOL isHaveTitle;
|
|
@end
|
|
@implementation XPPrivilegeCardConfirmView
|
|
|
|
-(instancetype)initInstructionsWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
[self installUIWithTitle];
|
|
[self installConstraintsWithTitle];
|
|
}
|
|
return self;
|
|
}
|
|
|
|
-(instancetype)initWithFrame:(CGRect)frame WithTitle:(BOOL)is{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
self.isHaveTitle = is;
|
|
[self installUIWithInstructions];
|
|
[self installConstraintsWithInstructions];
|
|
}
|
|
return self;
|
|
}
|
|
-(instancetype)initWithFrame:(CGRect)frame{
|
|
self = [super initWithFrame:frame];
|
|
if(self){
|
|
|
|
[self installUI];
|
|
[self installConstraints];
|
|
}
|
|
return self;
|
|
}
|
|
-(void)installUIWithInstructions{
|
|
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
|
|
[self addSubview:self.bgView];
|
|
[self.bgView addSubview:self.titleView];
|
|
[self.bgView addSubview:self.contentView];
|
|
|
|
[self.bgView addSubview:self.verifyBtn];
|
|
self.titleView.text = @"关于特权卡";
|
|
self.titleView.font = kFontMedium(16);
|
|
self.contentView.font = kFontRegular(14);
|
|
self.contentView.text = @"1. 特权卡是用户在房间内身份的象征,送出特权卡可增加用户之间互动。\n2. 特权卡由房主和房间管理员发放";
|
|
[self.verifyBtn setTitle:@"知道了" forState:UIControlStateNormal];
|
|
}
|
|
-(void)installConstraintsWithInstructions{
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(kGetScaleWidth(307));
|
|
make.height.mas_greaterThanOrEqualTo(kGetScaleWidth(223));
|
|
make.center.equalTo(self);
|
|
}];
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(28));
|
|
make.centerX.equalTo(self.bgView);
|
|
}];
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(68));
|
|
make.leading.trailing.equalTo(self.bgView).inset(kGetScaleWidth(10));
|
|
make.centerX.equalTo(self.bgView);
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(84));
|
|
}];
|
|
|
|
[self.verifyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(24));
|
|
make.width.mas_equalTo(kGetScaleWidth(244));
|
|
make.centerX.equalTo(self.bgView);
|
|
make.height.mas_equalTo(kGetScaleWidth(40));
|
|
}];
|
|
}
|
|
-(void)installUIWithTitle{
|
|
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
|
|
[self addSubview:self.bgView];
|
|
[self.bgView addSubview:self.titleView];
|
|
[self.bgView addSubview:self.contentView];
|
|
|
|
[self.bgView addSubview:self.verifyBtn];
|
|
[self.verifyBtn setTitle:@"知道了" forState:UIControlStateNormal];
|
|
}
|
|
-(void)installConstraintsWithTitle{
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(kGetScaleWidth(307));
|
|
make.height.mas_greaterThanOrEqualTo(kGetScaleWidth(184));
|
|
make.center.equalTo(self);
|
|
}];
|
|
[self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(48));
|
|
make.centerX.equalTo(self.bgView);
|
|
}];
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(72));
|
|
make.leading.trailing.equalTo(self.bgView).inset(kGetScaleWidth(10));
|
|
make.centerX.equalTo(self.bgView);
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(92));
|
|
}];
|
|
|
|
[self.verifyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(24));
|
|
make.width.mas_equalTo(kGetScaleWidth(244));
|
|
make.centerX.equalTo(self.bgView);
|
|
make.height.mas_equalTo(kGetScaleWidth(40));
|
|
}];
|
|
}
|
|
-(void)installUI{
|
|
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.6];
|
|
[self addSubview:self.bgView];
|
|
[self.bgView addSubview:self.contentView];
|
|
[self.bgView addSubview:self.cancelBtn];
|
|
[self.bgView addSubview:self.verifyBtn];
|
|
}
|
|
|
|
-(void)installConstraints{
|
|
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.width.mas_equalTo(kGetScaleWidth(307));
|
|
make.height.mas_greaterThanOrEqualTo(kGetScaleWidth(184));
|
|
make.center.equalTo(self);
|
|
}];
|
|
[self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.top.mas_equalTo(kGetScaleWidth(48));
|
|
make.leading.trailing.equalTo(self.bgView).inset(kGetScaleWidth(10));
|
|
make.centerX.equalTo(self.bgView);
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(92));
|
|
}];
|
|
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
make.bottom.mas_equalTo(-kGetScaleWidth(24));
|
|
make.width.mas_equalTo(kGetScaleWidth(124));
|
|
make.height.mas_equalTo(kGetScaleWidth(40));
|
|
make.leading.mas_equalTo(kGetScaleWidth(24));
|
|
}];
|
|
[self.verifyBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
|
|
|
make.top.width.height.equalTo(self.cancelBtn);
|
|
make.trailing.mas_equalTo(-kGetScaleWidth(24));
|
|
}];
|
|
}
|
|
-(void)setText:(NSString *)text{
|
|
_text = text;
|
|
_contentView.text = text;
|
|
}
|
|
-(void)setTextAtt:(NSMutableAttributedString *)textAtt{
|
|
_textAtt = textAtt;
|
|
_contentView.attributedText = _textAtt;
|
|
}
|
|
-(void)cancelAction{
|
|
[TTPopup dismiss];
|
|
}
|
|
-(void)verifyAction{
|
|
[TTPopup dismiss];
|
|
if(self.isHaveTitle == YES)return;
|
|
if(self.confirmHanle){
|
|
self.confirmHanle();
|
|
}
|
|
}
|
|
#pragma mark - 懒加载
|
|
-(UIView *)bgView{
|
|
if(!_bgView){
|
|
_bgView = [UIView new];
|
|
_bgView.backgroundColor = [UIColor whiteColor];
|
|
_bgView.layer.cornerRadius = kGetScaleWidth(16);
|
|
_bgView.layer.masksToBounds = YES;
|
|
}
|
|
return _bgView;
|
|
}
|
|
-(UILabel *)titleView{
|
|
if(!_titleView){
|
|
_titleView = [UILabel labelInitWithText:@"审核不通过原因" font:kFontRegular(15) textColor:UIColorFromRGB(0x2B2D33)];
|
|
_titleView.textAlignment = NSTextAlignmentCenter;
|
|
_titleView.numberOfLines = 0;
|
|
}
|
|
return _titleView;
|
|
}
|
|
- (UIButton *)cancelBtn{
|
|
if(!_cancelBtn){
|
|
_cancelBtn = [UIButton new];
|
|
[_cancelBtn setTitle:@"取消" forState:UIControlStateNormal];
|
|
_cancelBtn.titleLabel.font = kFontMedium(14);
|
|
[_cancelBtn setTitleColor:UIColorFromRGB(0x2B2D33) forState:UIControlStateNormal];
|
|
_cancelBtn.backgroundColor = UIColorRGBAlpha(0xFFDA24, 0.2);
|
|
_cancelBtn.layer.cornerRadius = kGetScaleWidth(40)/2;
|
|
_cancelBtn.layer.masksToBounds = YES;
|
|
[_cancelBtn addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _cancelBtn;
|
|
}
|
|
-(UIButton *)verifyBtn{
|
|
if(!_verifyBtn){
|
|
_verifyBtn = [UIButton new];
|
|
[_verifyBtn setTitle:@"确认" forState:UIControlStateNormal];
|
|
_verifyBtn.titleLabel.font = kFontMedium(14);
|
|
[_verifyBtn setTitleColor:UIColorFromRGB(0x2B2D33) forState:UIControlStateNormal];
|
|
_verifyBtn.backgroundColor = UIColorFromRGB(0xFFDA24);
|
|
_verifyBtn.layer.cornerRadius = kGetScaleWidth(40)/2;
|
|
_verifyBtn.layer.masksToBounds = YES;
|
|
[_verifyBtn addTarget:self action:@selector(verifyAction) forControlEvents:UIControlEventTouchUpInside];
|
|
}
|
|
return _verifyBtn;
|
|
}
|
|
- (UILabel *)contentView{
|
|
if(!_contentView){
|
|
_contentView = [UILabel labelInitWithText:@"" font:kFontRegular(15) textColor:UIColorFromRGB(0x2B2D33)];
|
|
_contentView.textAlignment = NSTextAlignmentCenter;
|
|
_contentView.numberOfLines = 0;
|
|
}
|
|
return _contentView;
|
|
}
|
|
@end
|