123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- //
- // ASBaseViewController.m
- // Asteria
- //
- // Created by iOS on 2023/4/24.
- //
- #import "ASBaseViewController.h"
- @interface ASBaseViewController ()
- @property (nonatomic, strong) UIImageView *leftImgV;
- @property (nonatomic, strong) UITextField *searchTf;
- @property (nonatomic, strong) UIButton *tfBt;
- @property (nonatomic, copy) btnClickBlock tapSearchBlock;
- @property (nonatomic, strong) UIView *nav_bottomLineV;
- @end
- @implementation ASBaseViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- [self addBaseNav];
-
- self.navigationController.navigationBar.hidden = true;
-
- self.view.backgroundColor = _F8F8F8;
-
- }
- - (void)ucHomeStyle:(btnClickBlock)tapSearch {
- self.statusBgV.backgroundColor = Col_FFF;
- self.customNavBar.backgroundColor = Col_FFF;
- self.tapSearchBlock = tapSearch;
- [self.customNavBar addSubview:self.leftImgV];
- [self.customNavBar addSubview:self.searchTf];
- [self.customNavBar addSubview:self.tfBt];
-
- [self.leftImgV mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(self.customNavBar).offset(20);
- make.width.equalTo(@140);
- make.height.equalTo(@43.5);
- make.centerY.equalTo(self.customNavBar);
- }];
-
- [self.searchTf mas_makeConstraints:^(MASConstraintMaker *make) {
- make.leading.equalTo(self.leftImgV.mas_trailing).offset(20);
- make.height.equalTo(@36);
- make.centerY.equalTo(self.leftImgV);
- make.trailing.equalTo(self.customNavBar).offset(-10);
- }];
- [self.tfBt mas_makeConstraints:^(MASConstraintMaker *make) {
- make.edges.equalTo(self.searchTf);
- }];
-
- }
- - (void)addBaseNav {
-
- [self.view addSubview:self.statusBgV];
- [self.view addSubview:self.customNavBar];
- [self.customNavBar addSubview:self.nav_bottomLineV];
- self.statusBgV.frame = CGRectMake(0, 0, KScreenWidth, kStatusBarH);
- self.customNavBar.frame = CGRectMake(0, kStatusBarH, KScreenWidth, kCustomNavBarH);
- self.nav_bottomLineV.frame = CGRectMake(0, kCustomNavBarH-1, KScreenWidth, 1);
- }
- // MARK: - actions
- - (void)searchBtAction {
- if (self.tapSearchBlock) {
- self.tapSearchBlock();
- }
- }
- // MARK: - subVs
- - (UIView *)statusBgV {
- if (!_statusBgV) {
- UIView *v = [UIView baseV];
- v.backgroundColor = _32CFB0;
- _statusBgV = v;
- }
- return _statusBgV;
- }
- - (UIView *)customNavBar {
- if (!_customNavBar) {
- UIView *v = [UIView baseV];
- v.backgroundColor = _32CFB0;
- _customNavBar = v;
- }
- return _customNavBar;
- }
- - (UIView *)nav_bottomLineV {
- if (!_nav_bottomLineV) {
- UIView *v = [UIView baseV];
- v.backgroundColor = [UIColor.blackColor colorWithAlphaComponent:0.05];
- _nav_bottomLineV = v;
- }
- return _nav_bottomLineV;
- }
- - (UIImageView *)leftImgV {
- if (!_leftImgV) {
- UIImageView *v = [UIImageView baseImgV];
- v.image = [UIImage imageNamed:@"nav_icon"];
- _leftImgV = v;
- }
- return _leftImgV;
- }
- - (UITextField *)searchTf {
- if (!_searchTf) {
- UITextField *tf = [[UITextField alloc] init];
- tf.borderStyle = UITextBorderStyleNone;
- UIView *leftV = [[UIView alloc] init];
- leftV.backgroundColor = UIColor.clearColor;
- UIImageView *imgV = [UIImageView baseImgV];
- imgV.backgroundColor = UIColor.clearColor;
- imgV.image = [UIImage imageNamed:@"nav_search"];
- leftV.frame = CGRectMake(0, 0, 44, 36);
- imgV.frame = CGRectMake(10, 6, 24, 24);
- [leftV addSubview:imgV];
- tf.leftView = leftV;
- tf.leftViewMode = UITextFieldViewModeAlways;
- tf.backgroundColor = _F5F5F5;
- tf.layer.cornerRadius = 5;
- tf.layer.masksToBounds = true;
- _searchTf = tf;
- }
- return _searchTf;
- }
- - (UIButton *)tfBt {
- if (!_tfBt) {
- UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
- [bt addTarget:self action:@selector(searchBtAction) forControlEvents:UIControlEventTouchUpInside];
- _tfBt = bt;
- }
- return _tfBt;
- }
- @end
|