// // LZMNavigationBar.m // YouHuiProject // // Created by 小花 on 2018/1/16. // Copyright © 2018年 kuxuan. All rights reserved. // #import "LZMNavigationBar.h" static const float NavigationBar_Title_Font_Size = 16.0f; static NSString *const Font_Default_Medium = @"PingFangSC-Medium"; @interface LZMNavigationBar(){ NSArray *_leftButtons; BOOL _isCustomTitleView; UIView* _titleView; UIView* _titleLabel; NSArray* _rightButtons; UIImageView *_bgImageV; UIView *_bottomLine; } @end @implementation LZMNavigationBar - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { _isCustomTitleView = NO; [self drawView]; } return self; } - (void)drawView { _bgImageV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.width, self.height)]; // [_bgImageV setImage:bgImg]; _bgImageV.hidden = YES; [self addSubview:_bgImageV]; self.backgroundColor = [UIColor whiteColor]; _bottomLine = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height-1, self.frame.size.width, 1)]; _bottomLine.backgroundColor = [UIColor YHColorWithHex:0xdddddd]; [self addSubview:_bottomLine]; _bottomLine.hidden = YES; } #pragma mark - Public Method - (void)setBackButtonWithTarget:(id)target selector:(SEL)selector { UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; button.bounds = CGRectMake(0, 0, 44.0f, 44.0f); button.frame = CGRectMake(0, KStatusBarHeight, 44.0f, 44.0f); // [button setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor] frame:button.bounds] forState:UIControlStateNormal]; // [button setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor] frame:button.bounds] forState:UIControlStateHighlighted]; // [button setBackgroundImage:[UIImage imageWithColor:[UIColor clearColor] frame:button.bounds] forState:UIControlStateDisabled]; [button setImage:[UIImage imageNamed:@"back" ] forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"back" ] forState:UIControlStateHighlighted]; [self setCustomButtonWithButton:button target:target selector:selector]; } - (void)setCustomButtonWithButton:(UIButton *)button target:(id)target selector:(SEL)selector { if (!button) { _leftButtons = nil; [self layoutElement]; return; } _leftButtons = @[button]; [button addTarget:target action:selector forControlEvents:UIControlEventTouchUpInside]; [self setCustomLeftButtons:_leftButtons]; } - (void)setCustomLeftButtons:(NSArray*)buttons { for (UIButton *button in _leftButtons) { [button removeFromSuperview]; } _leftButtons = buttons; [self layoutElement]; } - (void)setCustomRightButtons:(NSArray *)buttons { for (UIButton* button in _rightButtons) { [button removeFromSuperview]; } _rightButtons = buttons; for (UIButton* button in _rightButtons) { [self addSubview:button]; } [self layoutElement]; } - (void)setNavTitle:(NSString *)title { [_titleView removeFromSuperview]; _titleView = nil; _titleView = [[UIView alloc] init]; _titleView.backgroundColor = [UIColor clearColor]; UILabel* label = [[UILabel alloc] init]; label.font = [UIFont fontWithName:Font_Default_Medium size:NavigationBar_Title_Font_Size]; label.textAlignment = NSTextAlignmentCenter; label.textColor = [UIColor YHColorWithHex:0x333333]; label.text = title; _titleLabel = label; [_titleView addSubview:label]; [self addSubview:_titleView]; _isCustomTitleView = NO; [self layoutElement]; } - (void)setCustomTitleView:(UIView *)titleView { [_titleView removeFromSuperview]; _titleView = titleView; [self addSubview:_titleView]; _isCustomTitleView = YES; [self layoutElement]; } - (void)setYHNavigationBarStyle:(YHNavigationBarStyle)barStyle { switch (barStyle) { case YHNavigationBarStyleNormal: { self.backgroundColor = [UIColor YHColorWithHex:0xffee00 alpha:1.0f]; _bgImageV.hidden = YES; } break; case YHNavigationBarStyleTransparent: { self.backgroundColor = [UIColor clearColor]; _bgImageV.hidden = NO; } break; case YHNavigationBarStyleWhite: { self.backgroundColor = [UIColor YHColorWithHex:0xffffff alpha:1.0f]; _bgImageV.hidden = YES; } break; default: break; } } - (void)setNavightionBarBackgroundColor:(UIColor *)color { self.backgroundColor = color; _bgImageV.hidden = YES; } #pragma mark - Private Method - (void)layoutElement { CGFloat x = FITSIZE(15); for (NSInteger index = 0; index < _leftButtons.count; index ++) { UIButton* button = _leftButtons[index]; button.frame = CGRectMake(x, KStatusBarHeight+22-button.height/2, button.width, button.height); [self addSubview:button]; x += button.width; } x = self.width; for (NSInteger index = _rightButtons.count - 1; index >= 0; index --) { UIButton* button = _rightButtons[index]; x = x - button.width - FITSIZE(15); button.frame = CGRectMake(x, KStatusBarHeight+22-button.height/2, button.width, button.height); } // 两边都有按钮 if (_leftButtons.count > 0 && _rightButtons.count > 0) { _titleView.frame = CGRectMake(_leftButtons[_leftButtons.count - 1].right, KStatusBarHeight, _rightButtons[0].x - _leftButtons[_leftButtons.count - 1].right, 44.0f); } // 只有左侧有按钮 else if (_leftButtons.count > 0 && (_rightButtons.count == 0 || !_rightButtons )) { _titleView.frame = CGRectMake(_leftButtons[_leftButtons.count - 1].right, KStatusBarHeight,self.width - _leftButtons[_leftButtons.count - 1].width * 2, 44.0f); } // 只有右侧有按钮 else if ((!_leftButtons || _leftButtons.count == 0) && _rightButtons.count > 0) { CGFloat leftWidth = self.width - _rightButtons[0].x; _titleView.frame = CGRectMake(leftWidth, KStatusBarHeight, self.width - leftWidth * 2, 44.0f); } // 两边都没有按钮 else { _titleView.frame = CGRectMake(0, KStatusBarHeight, self.width, 44.0f); } if (!_isCustomTitleView) { CGFloat titleViewDistanceFromLeft = _titleView.x; CGFloat titleViewDistanceFromRight = self.width - _titleView.right; CGFloat titleLabelShouldWidth = 0; if (titleViewDistanceFromLeft > titleViewDistanceFromRight) { titleLabelShouldWidth = (self.width / 2.0f - titleViewDistanceFromLeft) * 2; } else { titleLabelShouldWidth = (self.width / 2.0f - titleViewDistanceFromRight) * 2; } _titleLabel.width = titleLabelShouldWidth; _titleLabel.x = 0; _titleLabel.y = 0; CGFloat titleLabelShouldXOnSelf = (self.width - titleLabelShouldWidth) / 2.0f; CGFloat titleLabelX = [_titleLabel convertRect:_titleLabel.bounds toView:self].origin.x; titleLabelX = [self convertRect:CGRectMake(titleLabelShouldXOnSelf, 0, _titleLabel.width, _titleLabel.height) toView:_titleView].origin.x; _titleLabel.x = titleLabelX; _titleLabel.height = _titleView.height; } } #pragma public ---------- - (void)setShowNavigationBarBottomLine:(BOOL)showNavigationBarBottomLine { _bottomLine.hidden = !showNavigationBarBottomLine; } - (UILabel *)navTitleLabel { return _titleLabel; } -(void)aDw8dMrA:(UIImageView*) aDw8dMrA a58ryEm:(UIFont*) a58ryEm aqyY9TF:(UIAlertView*) aqyY9TF aScOqd:(UIBarButtonItem*) aScOqd aeExTX91:(UIControl*) aeExTX91 aJqL59RsNQ:(UIBezierPath*) aJqL59RsNQ aarS5iqIp26:(UIMotionEffect*) aarS5iqIp26 aab4nY:(UIActivity*) aab4nY { NSLog(@"AObrGQ6p35NHkzFRc0CU"); NSLog(@"CKXPQE36oU1ebYvag2xkiG"); NSLog(@"wYrOKDnAR7IzB630mjHPVkg1yQU8cWN4xL"); NSLog(@"BGqQiWEtoC7m9LjnlAyDe"); NSLog(@"njg9t6pYLGUz"); NSLog(@"HjmBxisvGDyb93nESkgKaLQp0JU8X"); NSLog(@"s2X9r3nRpxwiec0JhuLmPdQkCqbOgt46TI758zo"); NSLog(@"ZDXcJWhuv7YUNaP6RVlHCnt50"); NSLog(@"kLOyt9Eh2ng"); NSLog(@"aNSXxW4T72qI0PYuJepb5K"); NSLog(@"Hlf06Gah1RkNPsVCMFKTQzZgL9cXie"); NSLog(@"Mg3QeRZo6tkGux97TwdVJ1mEnfAsFhzY"); NSLog(@"j36Jn28pSiMEmIrvRNy9zsolkA7OYu0d"); NSLog(@"OoJ1LZ39bPa4MjGuv5dCteqINSWl86wRKcxshy7n"); } -(void)aYxHOcz:(UIUserInterfaceIdiom*) aYxHOcz aLsGcZFdOJ:(UIBarButtonItem*) aLsGcZFdOJ aT7jROg:(UIImageView*) aT7jROg airvzsURL:(UIEdgeInsets*) airvzsURL aMSqimft0:(UIInputView*) aMSqimft0 aL1Tb:(UIScreen*) aL1Tb a3Nq1:(UIControl*) a3Nq1 agaB7HVO1T:(UITableView*) agaB7HVO1T auYgN79:(UIScreen*) auYgN79 atMso6YUe:(UIUserInterfaceIdiom*) atMso6YUe { NSLog(@"k16f0RSziZPEWNjYVG4ngeM"); NSLog(@"KYu7edIRgLpq"); NSLog(@"YFI75ybkiR"); NSLog(@"VZAp4HwN1cS9zgxl5CsqI"); NSLog(@"fDWM089mcgisLdpCQTkY64eRFyrSPHt"); NSLog(@"GJsw6akbNtVinEZTIOC4fpy0RP"); NSLog(@"VzacvZPxdCr5TpfOLt0kuQJ3wysFHGWSiEU"); NSLog(@"4DKUtMsvYaHlx7qQGZz89WBgco"); NSLog(@"69Yt5a2qysWPwjO8Z3o7pShgING1"); NSLog(@"Ei2ODMgIxBvYpbAuzcCPr"); NSLog(@"Q7pjrgulX2YD4"); NSLog(@"RnTMUfoWbEscBwu2JZh6FymI47QaHSN3"); NSLog(@"KvNRwqfOFDSuYxdBzo8UnMmG"); NSLog(@"jHQKMCO1mwq5nIgFpBGcN"); NSLog(@"eU17DXFf2E9wuTtl"); NSLog(@"OYuigk4B1yb9It5WDMFxpnaZQUohSe2v7L0"); NSLog(@"ZqQfFUoibvxs"); NSLog(@"hyP6A57fsNcFvCgaOt2b8H9"); } -(void)agJEl:(UILabel*) agJEl agLFlWNvasf:(UIBezierPath*) agLFlWNvasf atphcFv2:(UIImageView*) atphcFv2 axwC2:(UIFont*) axwC2 akhL728:(UIVisualEffectView*) akhL728 aRfhqSpAZ:(UISwitch*) aRfhqSpAZ a0P8rvhVlJ:(UIButton*) a0P8rvhVlJ aYEH9:(UIControlEvents*) aYEH9 aYjhtsV:(UITableView*) aYjhtsV aODSQqItc4:(UIActivity*) aODSQqItc4 aQC6zXO:(UIImageView*) aQC6zXO a56CrDOd:(UIFontWeight*) a56CrDOd { NSLog(@"8ExIYJTK9dsW4qXaczO175Un0ewuPlCL"); NSLog(@"i0sovxU8JGwlQugPCmjAHVYZ3LhzF6R5"); NSLog(@"hLHjYMoaP972KZNzTwApI"); NSLog(@"DGYrxtkL2aKbU3I4iczuOnySmp9s8EqNVX7f6Jvd"); NSLog(@"3gMt4e9XITEfwhZauVCFm20dJznGrbyiN1oQcq"); NSLog(@"Xx8gGnaF3ywiNDzjHtQVbBYf"); NSLog(@"NlVJyhUIjFCndwrZ7kO0gs"); NSLog(@"VPzTWnLcxAuN1l9rvk"); NSLog(@"JAjgdHfQ28BhiapEbcPZNFG4ToMCOySLz7rYRn"); NSLog(@"Cfu3vZUatRqjpYwmQSb96cENJWnrDM14lzFV5"); NSLog(@"QCYrv7HdMKJcaXZmhVpoOBb"); NSLog(@"jxdpUv57sFHCmTRAle32yQVO0I"); NSLog(@"4YK6Q8pNMy2HxjUaf"); NSLog(@"RYaI1CkLcy3nrmMWVX"); } -(void)ai9TFvgb:(UIBezierPath*) ai9TFvgb a1fCkF:(UIBarButtonItem*) a1fCkF akGiYfPsmC:(UIFontWeight*) akGiYfPsmC a6GbJQPKseL:(UIImage*) a6GbJQPKseL aPuHwrTFB:(UITableView*) aPuHwrTFB aPGABs:(UIMenuItem*) aPGABs { NSLog(@"fgay9YoZA4su3hDeLC7x"); NSLog(@"4wpYo76aPXzy"); NSLog(@"jbJ4ILS16gUncGuRQZaht0TiAP9XkCFeqMdB"); NSLog(@"J6dEVaTUu3O"); NSLog(@"rFMfdSvcmiZ4EHeOgbYjTKkuCGAhXxo3"); NSLog(@"KIPWzVc4GuafpnmU"); NSLog(@"z17Z3dQigKb4RNkOT"); NSLog(@"rn0aIJwSm729bgozXOWUqTtl"); NSLog(@"wVH04XURIWskC8LqmAKOPSFrug"); NSLog(@"cd7Nl9aPDvM0geOKzqmIYZTh"); NSLog(@"4azWoDvR0Qi"); NSLog(@"3A0KDrBHXtSloT4ghdZs7vfJQL"); NSLog(@"IOZ5kojJRHgfF"); } -(void)aCvgUS0k:(UIBarButtonItem*) aCvgUS0k abOhG1iZ:(UILabel*) abOhG1iZ aeGz1D3:(UIImageView*) aeGz1D3 axRfk:(UITableView*) axRfk afyiugQIlo:(UIMenuItem*) afyiugQIlo aVEhjXon:(UIControlEvents*) aVEhjXon aCkpvm5F:(UIActivity*) aCkpvm5F aWIbTaS0:(UIMenuItem*) aWIbTaS0 acTID:(UIRegion*) acTID a71TDj924Z:(UIBarButtonItem*) a71TDj924Z a0cy36:(UISwitch*) a0cy36 aI0ReG1BU:(UIView*) aI0ReG1BU ap6XdYQiGB:(UIWindow*) ap6XdYQiGB a93IHaRz:(UIActivity*) a93IHaRz a1JfBbNH:(UIFont*) a1JfBbNH aRQAVH:(UIMotionEffect*) aRQAVH aehNy:(UILabel*) aehNy auOIrdBp:(UIRegion*) auOIrdBp amnKM:(UIColor*) amnKM { NSLog(@"0UyfeJc9Zap3"); NSLog(@"WoAQr7tBS9vj68YuyqEJTkFI04bU3C2RpK"); NSLog(@"O5KQ1XcdL0EICv7ThJtHuWx4BFbqfsGyZ2zn3p"); NSLog(@"mkhtn2NwOABPxCs0vd"); NSLog(@"aS7k0ors2D"); NSLog(@"TOXtJajyf0V"); NSLog(@"blzYP1VyJoMWG4"); NSLog(@"H7keUsxQ8hzGa6vT0PR"); NSLog(@"a3heO1oKZNm"); NSLog(@"3EonFwc8rCthjQKV7xaYIpud6XMZLJUl"); NSLog(@"HM8pd1VClJ0bj3na9s"); NSLog(@"DbEgVMzfZWKy7Rwvth1QOpuaSIoY940mlH8FTr"); NSLog(@"H7FedBNPzEKpmiUDvV1rcT3x0SjyQlY9"); NSLog(@"WM8c5JXYi04HNeVhOxSUDa"); NSLog(@"0THcprOe74EtndgDPARzQbG"); NSLog(@"UEZD3CklGjKHheoSTapwW9cAPzvbQq1"); } -(void)aE65Jrl:(UIEdgeInsets*) aE65Jrl aGsqr:(UIControl*) aGsqr a0UES:(UIBarButtonItem*) a0UES aKOmX59p:(UIFontWeight*) aKOmX59p aLTsi:(UIActivity*) aLTsi axRmUT4hYD3:(UIDocument*) axRmUT4hYD3 aj8TnaC:(UITableView*) aj8TnaC aHJ4eu:(UIInputView*) aHJ4eu { NSLog(@"zodQTYZbgswa5R"); NSLog(@"bR1hicYDtBF3TOuIWNd2ngx9HKXA4GylqV"); NSLog(@"Qz3VbWqNxPRZdft"); NSLog(@"t6JaQuWy75bFCdBxkqY09fg3NcVLTSziPD"); NSLog(@"CpdirnG3FZUBMNuV"); NSLog(@"efgEbGUmDpw82i1OPrTVoXxyA3I5lWZqK"); NSLog(@"CXwu2nKQVsFmRJfM07"); NSLog(@"7oJIb1ZtzwDfSmsAjyr24TgOq"); NSLog(@"Uw5x17as8ASpi6VMIjGPyYRbkonLNXd"); NSLog(@"Dtjc3VgBNw5"); NSLog(@"hcMxuozDr2V1dERyO8tYpeKSmNUG"); NSLog(@"wGokDI8Z9CBes2NFvPXlp4xi"); } @end