-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathCategorySearchBar.m
More file actions
51 lines (44 loc) · 1.42 KB
/
CategorySearchBar.m
File metadata and controls
51 lines (44 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// CategorySearchBar.m
// Coding_iOS
//
// Created by jwill on 15/11/18.
// Copyright © 2015年 Coding. All rights reserved.
//
#import "CategorySearchBar.h"
@interface CategorySearchBar ()
@end
@implementation CategorySearchBar
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self setSearchFieldBackgroundImage:[UIImage imageWithColor:[UIColor colorWithHexString:@"0xEBECEC"] withFrame:CGRectMake(0, 0, 1, 28)] forState:UIControlStateNormal];
UITextField *searchField = self.eaTextField;
searchField.layer.masksToBounds = YES;
searchField.layer.cornerRadius = 4.0;
}
return self;
}
-(void)layoutSubviews{
[super layoutSubviews];
UITextField *searchField = self.eaTextField;
searchField.leftView.frame = CGRectMake(8, (CGRectGetHeight(searchField.bounds) - 13)/2, 20, 13);
searchField.leftView.contentMode = UIViewContentModeLeft;
}
@end
@implementation MainSearchBar
- (UIButton *)scanBtn{
if (!_scanBtn) {
_scanBtn = [UIButton new];
[_scanBtn setImage:[UIImage imageNamed:@"button_scan"] forState:UIControlStateNormal];
[self addSubview:_scanBtn];
[_scanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(50, 30));
make.centerY.equalTo(self);
make.right.equalTo(self);
}];
}
return _scanBtn;
}
@end