Files
fanyin-ios/QXLive/Mine(音域)/View/个人主页/相册/QXPhotoPasswordView.m
2025-08-12 14:27:12 +08:00

100 lines
4.2 KiB
Objective-C

//
// QXPhotoPasswordView.m
// QXLive
//
// Created by 启星 on 2025/5/29.
//
#import "QXPhotoPasswordView.h"
@interface QXPhotoPasswordView()
@property (nonatomic,strong)UILabel *titleLabel;
@property (nonatomic,strong)UIButton *closeBtn;
@property (nonatomic,strong)UILabel *messageLabel;
@property (nonatomic,strong)UIView *textBgView;
@property (nonatomic,strong)UITextField *textField;
@property (nonatomic,strong)UIButton*cancelBtn;
@property (nonatomic,strong)UIButton*commitBtn;
@end
@implementation QXPhotoPasswordView
- (instancetype)init
{
self = [super init];
if (self) {
self.frame = CGRectMake(0, 0, ScaleWidth(300), ScaleWidth(200));
self.backgroundColor = [UIColor whiteColor];
[self addRoundedCornersWithRadius:16];
[self initSubviews];
}
return self;
}
-(void)initSubviews{
self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 12, self.width-80, 24)];
self.titleLabel.font = [UIFont boldSystemFontOfSize:16];
self.titleLabel.textColor = QXConfig.textColor;
self.titleLabel.text = QXText(@"温馨提示");
self.titleLabel.textAlignment = NSTextAlignmentCenter;
[self addSubview:self.titleLabel];
self.closeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.width-40, 0, 40, 40)];
[self.closeBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.closeBtn setImage:[UIImage imageNamed:@"wallet_close"] forState:(UIControlStateNormal)];
[self addSubview:self.closeBtn];
self.messageLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, self.titleLabel.bottom+12, self.width-24, 21)];
self.messageLabel.font = [UIFont systemFontOfSize:14];
self.messageLabel.textColor = QXConfig.textColor;
self.messageLabel.text = QXText(@"确认开启相册私密吗");
[self addSubview:self.messageLabel];
self.textBgView = [[UIView alloc] initWithFrame:CGRectMake(12, self.messageLabel.bottom+12, self.width-24, 44)];
[self.textBgView addRoundedCornersWithRadius:11];
self.textBgView.backgroundColor = RGB16(0xeff2f8);
[self addSubview:self.textBgView];
self.textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 0, self.textBgView.width-24, 44)];
self.textField.font = [UIFont systemFontOfSize:16];
self.textField.textColor = QXConfig.textColor;
self.textField.placeholder = QXText(@"请输入密码");
[self.textBgView addSubview:self.textField];
CGFloat btnWidth = (self.width-19*2-16) / 2;
self.cancelBtn = [[UIButton alloc] initWithFrame:CGRectMake(19, self.textBgView.bottom+23, btnWidth, 42)];
[self.cancelBtn setTitle:QXText(@"取消") forState:(UIControlStateNormal)];
[self.cancelBtn setTitleColor:RGB16(0x999999) forState:(UIControlStateNormal)];
self.cancelBtn.backgroundColor = RGB16(0xf3f3f3);
self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.cancelBtn addTarget:self action:@selector(closeAction) forControlEvents:(UIControlEventTouchUpInside)];
[self.cancelBtn addRoundedCornersWithRadius:21];
[self addSubview:self.cancelBtn];
self.commitBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.cancelBtn.right+16, self.cancelBtn.top, btnWidth, 42)];
[self.commitBtn setTitle:QXText(@"确认") forState:(UIControlStateNormal)];
[self.commitBtn setTitleColor:QXConfig.btnTextColor forState:(UIControlStateNormal)];
self.commitBtn.backgroundColor = QXConfig.themeColor;
[self.commitBtn addTarget:self action:@selector(commitAction) forControlEvents:(UIControlEventTouchUpInside)];
self.commitBtn.titleLabel.font = [UIFont systemFontOfSize:14];
[self.commitBtn addRoundedCornersWithRadius:21];
[self addSubview:self.commitBtn];
}
-(void)setModel:(QXPhotoModel *)model{
_model = model;
}
-(void)closeAction{
[[QXGlobal shareGlobal] hideViewBlock:^{
}];
}
-(void)commitAction{
MJWeakSelf
[[QXGlobal shareGlobal] hideViewBlock:^{
if (weakSelf.delegate && [self.delegate respondsToSelector:@selector(didClickCommitWithPassword:model:)]) {
[weakSelf.delegate didClickCommitWithPassword:weakSelf.textField.text model:self.model];
}
}];
}
@end