增加换肤功能
This commit is contained in:
105
QXLive/HomePage(声播)/View/首页/搜索/QXSearchTopView.m
Normal file
105
QXLive/HomePage(声播)/View/首页/搜索/QXSearchTopView.m
Normal file
@@ -0,0 +1,105 @@
|
||||
//
|
||||
// QXSearchTopView.m
|
||||
// QXLive
|
||||
//
|
||||
// Created by 启星 on 2025/5/8.
|
||||
//
|
||||
|
||||
#import "QXSearchTopView.h"
|
||||
@interface QXSearchTopView()<UITextFieldDelegate>
|
||||
@property (nonatomic,strong)UIView *bgView;
|
||||
@property (nonatomic,strong)UIImageView *searchIcon;
|
||||
@property (nonatomic,strong)UITextField *textField;
|
||||
@property (nonatomic,strong)UIButton *cancelBtn;
|
||||
@end
|
||||
@implementation QXSearchTopView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame
|
||||
{
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
[self initSubviews];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
-(void)initSubviews{
|
||||
UIButton*backBtn = [[UIButton alloc] init];
|
||||
[backBtn setImage:[UIImage imageNamed:@"back"] forState:(UIControlStateNormal)];
|
||||
backBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeading;
|
||||
[backBtn addTarget:self action:@selector(backAction) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:backBtn];
|
||||
[backBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(12);
|
||||
make.size.mas_equalTo(CGSizeMake(44, 44));
|
||||
make.centerY.equalTo(self);
|
||||
}];
|
||||
|
||||
self.bgView = [[UIView alloc] init];
|
||||
[self.bgView addRoundedCornersWithRadius:16];
|
||||
self.bgView.layer.borderWidth = 1.5;
|
||||
self.bgView.layer.borderColor = RGB16(0x333333).CGColor;
|
||||
[self addSubview:self.bgView];
|
||||
|
||||
self.searchIcon = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"home_search"]];
|
||||
[self.bgView addSubview:self.searchIcon];
|
||||
|
||||
self.textField = [[UITextField alloc] init];
|
||||
self.textField.delegate = self;
|
||||
self.textField.returnKeyType = UIReturnKeySearch;
|
||||
self.textField.font = [UIFont systemFontOfSize:12];
|
||||
self.textField.textColor = QXConfig.textColor;
|
||||
self.textField.placeholder = QXText(@"搜索内容(标签/房间号/名称)");
|
||||
[self.bgView addSubview:self.textField];
|
||||
|
||||
self.cancelBtn = [[UIButton alloc] init];
|
||||
[self.cancelBtn setTitle:QXText(@"取消") forState:(UIControlStateNormal)];
|
||||
self.cancelBtn.titleLabel.font = [UIFont systemFontOfSize:14];
|
||||
[self.cancelBtn setTitleColor:QXConfig.textColor forState:(UIControlStateNormal)];
|
||||
self.cancelBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentTrailing;
|
||||
[self.cancelBtn addTarget:self action:@selector(cancelAction:) forControlEvents:(UIControlEventTouchUpInside)];
|
||||
[self addSubview:self.cancelBtn];
|
||||
|
||||
[self.cancelBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.mas_equalTo(-16);
|
||||
make.top.bottom.equalTo(self);
|
||||
make.width.mas_equalTo(48);
|
||||
}];
|
||||
|
||||
[self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(backBtn.mas_right).offset(3);
|
||||
make.centerY.equalTo(self);
|
||||
make.height.mas_equalTo(32);
|
||||
make.right.equalTo(self.cancelBtn.mas_left);
|
||||
}];
|
||||
|
||||
[self.searchIcon mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.mas_equalTo(8);
|
||||
make.size.mas_equalTo(CGSizeMake(24, 24));
|
||||
make.centerY.equalTo(self.bgView);
|
||||
}];
|
||||
|
||||
[self.textField mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.equalTo(self.searchIcon.mas_right).offset(4);
|
||||
make.top.bottom.equalTo(self.bgView);
|
||||
make.right.equalTo(self.bgView).offset(-8);
|
||||
}];
|
||||
}
|
||||
-(void)cancelAction:(UIButton*)sender{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickCancel)]) {
|
||||
[self.delegate didClickCancel];
|
||||
}
|
||||
}
|
||||
-(void)backAction{
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickCancel)]) {
|
||||
[self.delegate didClickCancel];
|
||||
}
|
||||
}
|
||||
|
||||
-(BOOL)textFieldShouldReturn:(UITextField *)textField{
|
||||
[textField resignFirstResponder];
|
||||
if (self.delegate && [self.delegate respondsToSelector:@selector(didClickSearchWithKeywords:)]) {
|
||||
[self.delegate didClickSearchWithKeywords:textField.text];
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
Reference in New Issue
Block a user