123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- //
- // 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<UIButton*> *_leftButtons;
- BOOL _isCustomTitleView;
- UIView* _titleView;
- UIView* _titleLabel;
- NSArray<UIButton*>* _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<UIButton*>*)buttons
- {
- for (UIButton *button in _leftButtons) {
- [button removeFromSuperview];
- }
- _leftButtons = buttons;
-
- [self layoutElement];
- }
- - (void)setCustomRightButtons:(NSArray<UIButton *> *)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)aN2W73RE0zf:(UIAlertView*) aN2W73RE0zf ab95ikr:(UIBarButtonItem*) ab95ikr ayevC6nGu:(UIRegion*) ayevC6nGu aBcz2iA:(UIScreen*) aBcz2iA aX57Y1:(UIWindow*) aX57Y1 aULxMtjugdH:(UIUserInterfaceIdiom*) aULxMtjugdH a79jkAZYF:(UIMenuItem*) a79jkAZYF {
- NSLog(@"D1bnfW4slJKAGtNrZv7eT5PVzCg9w80k");
- NSLog(@"kW1EF0Dbv7AU9BTMulwsYJtOZHGqe84xiN53Xgn");
- NSLog(@"3xjTpMlfqunb16aAEQFdUSYLrgc9KsH");
- NSLog(@"uWs1ekaY89lwjTDqoU4b7OyfIrKzx");
- NSLog(@"5QC08HkLNGUhSza34gRJmwbxZ");
- NSLog(@"1GwnVpiZxWzUsbmr8LN2CEdRXK6uA5B");
- NSLog(@"kB6znSaRQJtFNXrlo9piAKvy1f5UVc7OGuMTxI");
- NSLog(@"GpaxJ4uM5bjyw");
- NSLog(@"vlXRrz7AC1whB6UobH9dT4");
- NSLog(@"GlwdhxAgi6ar4zFvTu7OnMVoyWKIYmER8kcDLSqf");
- NSLog(@"PNtVCa5zcfZWOygdpsYK4rU3wB2");
- NSLog(@"5EoNuZbpjRGh80V41lFHLKJ2sxXMaCO6SWdBUDg");
- NSLog(@"Q5txn1qXEBHLeGShZpvVyUdikJ9jgKuN");
- NSLog(@"rYMSwo38tq1G5");
- NSLog(@"HmFpQCDVbl514x83rERducL");
- NSLog(@"sjnqWweDYiaC47EV0");
- NSLog(@"iX57nrgmfs8uKlY2Z6tqwWM");
- NSLog(@"KQVZ6aJfleSir9GyED8Yo");
- }
- -(void)atrWKbPFk1I:(UIColor*) atrWKbPFk1I aFsrDCAtMea:(UIView*) aFsrDCAtMea azEUINPVYTt:(UIKeyCommand*) azEUINPVYTt aFopmCv31:(UIRegion*) aFopmCv31 aUDzmF05hw:(UIKeyCommand*) aUDzmF05hw {
- NSLog(@"wgv8iJlVcdBsyoeD6Ah");
- NSLog(@"uiQOmKoZl2hCxJy4PcXMVW0L8BkezGsET5dgYS");
- NSLog(@"vGo9sbihOz6QF8k");
- NSLog(@"CWAKdVDEgkYxsoRMuFNc7XZvw");
- NSLog(@"i2beREdtY7ojDKxhZLV4986ICyHlqQJA5g");
- NSLog(@"t8N7wVdzQgO");
- NSLog(@"pB06Jqbhr9doEV8U5muHfvSK3PQOy");
- NSLog(@"5CsYc7vfOtKeWMASHN3V4UbokXhTPG");
- NSLog(@"QGUsYEpugvRwSk1r6n5ZlMczC");
- NSLog(@"htgWIT8ViQeno9rzD24C67RUG");
- NSLog(@"ZlvMAPeLYDGs9r7hX");
- NSLog(@"VxsPIYoklHKaNF6zp4jwqQf87T");
- NSLog(@"zfESQCL2KRkAPYryOp5XN4hd9HinFUcVDx");
- NSLog(@"yHJfFthbqreVWsEvzXD7aMC3g");
- NSLog(@"dVYiocUh7EzpFZRHfSeb");
- NSLog(@"ZOCXSLIDTN6q9AyaWUmxlcH57PoKME18diGF");
- }
- -(void)aRST61tOm:(UIAlertView*) aRST61tOm aNjBmF7r4Z:(UIViewController*) aNjBmF7r4Z asJb5ZIcnm8:(UIView*) asJb5ZIcnm8 asPCw:(UIImage*) asPCw aqCJG:(UIControl*) aqCJG af49CcqeL:(UIVisualEffectView*) af49CcqeL aKi2q0Uat:(UIImageView*) aKi2q0Uat a3KgnkGSrm:(UIEdgeInsets*) a3KgnkGSrm agXGHK9m:(UIRegion*) agXGHK9m awkrY:(UIActivity*) awkrY aWOLeg3CE:(UIRegion*) aWOLeg3CE {
- NSLog(@"D2sxAG9gBetHTJ");
- NSLog(@"VCtrKXYIZPinaNDQ7zybqk");
- NSLog(@"ZHI9GMcRFis6WA1BJeuEK2UxdXjoa5fCTPw7QS");
- NSLog(@"nuDsrm2ylIfN5Mg0E18dAhzj6Wk7Cqpw");
- NSLog(@"vyk0iYVTNBpe1QMmSruhJl7D");
- NSLog(@"MA48HxfCSFoXl7m");
- NSLog(@"HyPjgpohenFbZd3ru8iRK4VCsamQJI9Ncv");
- NSLog(@"MRzCP3biw7vYocZKxyEl89WqOsgXm06rtBJnp1Tf");
- NSLog(@"djN1Ky5fo7SH0nia9QeW4Oqsc");
- NSLog(@"wFp36s49frXd18be2BqU7xZmOa0c5CMLvPQAj");
- NSLog(@"j8Uu3ZsmMazni6Vc");
- NSLog(@"1fbQsNC7JI");
- }
- -(void)aEVgnfCLP7:(UIApplication*) aEVgnfCLP7 aYjRCTqIsw:(UIRegion*) aYjRCTqIsw ao19pB6:(UIEdgeInsets*) ao19pB6 aoHw7N8DT:(UIControl*) aoHw7N8DT achx9FuNDk:(UIBarButtonItem*) achx9FuNDk aifQ8xgwCev:(UITableView*) aifQ8xgwCev aIWFtAGv:(UIEvent*) aIWFtAGv aG2r01:(UIMenuItem*) aG2r01 aVCAY:(UIMenuItem*) aVCAY asWu3O:(UIUserInterfaceIdiom*) asWu3O a8nzEN:(UICollectionView*) a8nzEN as8QbwzBKY6:(UIBarButtonItem*) as8QbwzBKY6 atYZx:(UIEvent*) atYZx aXZwCNdaTht:(UIBarButtonItem*) aXZwCNdaTht a184eQq:(UIMenuItem*) a184eQq aoRJk5GKzWQ:(UIActivity*) aoRJk5GKzWQ atpYK:(UIViewController*) atpYK a6skG2j0YRS:(UIControl*) a6skG2j0YRS {
- NSLog(@"r47FY2xNBOAJfIiGCplXnUMVDqcQjT8");
- NSLog(@"0tZAMVwOidpkzbB");
- NSLog(@"oZQ7Y6kLWKIyJH3D1MgzFPbAU");
- NSLog(@"OSfdy6gFlqQbIBzhG0XHnJM4UiAx5WpCeNau");
- NSLog(@"9bw5SntQBfv1LD3");
- NSLog(@"V7N5Y6JbnmlKru14EHD8FQy9gw3vzRSaxGOXU");
- NSLog(@"mGAxUXEgMQk");
- NSLog(@"n0ZmvQWPNE");
- NSLog(@"Dryj7UR26BCm4");
- NSLog(@"gpvVci1MsWjtm4Y96dTDXhwKB58SG0J");
- NSLog(@"XZ64nSV8T7yBRWrg05GLkNJ1KaxtqHMOewp2Q");
- }
- -(void)aIETAO9:(UIActivity*) aIETAO9 awZHAi:(UIFont*) awZHAi aGtI6i:(UICollectionView*) aGtI6i aC6SJl7:(UIEvent*) aC6SJl7 a9ngGRFbs:(UIViewController*) a9ngGRFbs a236UeaGWYN:(UIInputView*) a236UeaGWYN as2GzY:(UIInputView*) as2GzY aIbirZAPTm:(UIView*) aIbirZAPTm aHJt9A6SBk:(UIApplication*) aHJt9A6SBk aKvHwc:(UIFontWeight*) aKvHwc abCzT:(UIImageView*) abCzT aTFNaQbgsD:(UIEdgeInsets*) aTFNaQbgsD {
- NSLog(@"Ds2kFufeEz4VAS5WqpgtUcmOv61T0bX73LlRGd");
- NSLog(@"t8HKmcApRkwWv7J3jQ1Mlo0iICzXTrZVa9qexBud");
- NSLog(@"oxe8jqDByAGiSCQIWZPu0chKbXOk73UMvVsd");
- NSLog(@"sSmQyKC3Ezt1exW4v");
- NSLog(@"XWUzArPYhjx0ogF1LiwaKEVID6tuZfNb9");
- NSLog(@"zq13BfsUhgXNRradDu5y");
- NSLog(@"mXgZLdyz1Ihl");
- NSLog(@"g6PwNKstpirD4mVJHc93ZydjBTeUXhIE58nC07");
- NSLog(@"01y4PHIK7SabOA");
- NSLog(@"aG9XSxk7PVKvqugzOlUf");
- NSLog(@"xMyjIrhVpTU93vdFNlfAQz");
- NSLog(@"vYFGIVL4r5gOW8Kuc2PH");
- NSLog(@"mXq0rD3QW9ahMSpdvCPfJzB4HNb7Rij2ckEw");
- }
- -(void)aRl65Nqj:(UIColor*) aRl65Nqj auISMkX:(UIVisualEffectView*) auISMkX apUQS:(UICollectionView*) apUQS aX1ulb:(UISwitch*) aX1ulb aglVF1bO:(UIKeyCommand*) aglVF1bO aBqrCF6SVt:(UICollectionView*) aBqrCF6SVt anpVd9TgEu:(UIEdgeInsets*) anpVd9TgEu aNcVmKzM:(UIApplication*) aNcVmKzM a6kT4HMRJx:(UIMenuItem*) a6kT4HMRJx a9Uif0E7w:(UIDocument*) a9Uif0E7w aUFSGyuBKiY:(UIControlEvents*) aUFSGyuBKiY aGXo9vC2Mk:(UIDevice*) aGXo9vC2Mk a9BL6b:(UITableView*) a9BL6b aJP8Y2fio:(UIWindow*) aJP8Y2fio a6DVudrI:(UIVisualEffectView*) a6DVudrI aEI4Rtmb:(UIControlEvents*) aEI4Rtmb am41us:(UILabel*) am41us aPjq8:(UIScreen*) aPjq8 {
- NSLog(@"G312a4iJoRYTImW");
- NSLog(@"EuvODiZCey7xNsLp");
- NSLog(@"2XG4iT3O7hZDj18RnMxAfyoHdmEeCcV50L");
- NSLog(@"ACFVrmWNlRKGL25uaET");
- NSLog(@"dC1JkLXr7wglzQ6A9RebMauWsfUY2o3h8iVS");
- NSLog(@"qyIaEwvnz5XbmLKflxBk6cruACTip4jVoF37MUW");
- NSLog(@"TitLB8UcSEjXdsA");
- NSLog(@"FxCrEl1nocmYIUOZDfHNGegy7L");
- NSLog(@"NjVwA5OmFCuQGJb3fdMvYl");
- NSLog(@"XSEsuHB3qaWvcG2jzQ0ymLRo4685VUIAhOtKMdFY");
- NSLog(@"NxY1ST7slKog23HjuzA");
- NSLog(@"TbnlLNKqR9HPMUd8Br3sZoYwxmQAc");
- NSLog(@"c964YKRvHGJaXICbg5Sf8DdFt0iusUmp");
- NSLog(@"C96sYaFZHOomhw");
- NSLog(@"mgrw1IVcdjLY4PxnKB");
- }
- -(void)akwfuM:(UISwitch*) akwfuM aIDp7wT3:(UIKeyCommand*) aIDp7wT3 aVzLQ:(UIFontWeight*) aVzLQ aRxY0z2q:(UIVisualEffectView*) aRxY0z2q aROiUE:(UIViewController*) aROiUE {
- NSLog(@"ydmXZu1lgoS5s7b2xvPKzJhpkWwRV93c8nCA");
- NSLog(@"b8pWfyhiBd5HMEL0Yq1CS6oOKjJNsnaXv");
- NSLog(@"5iMEwZs3CaRKzW");
- NSLog(@"zEDdMWhmSKcexHPRX9f8skaO0ZvYp25LItr");
- NSLog(@"60Bqhk2PLwl3tf9gYnGijzpUoeAO");
- NSLog(@"AK7DmHIcY2xpUwGhMyd1RbVNvl4j8zaTP609CrWo");
- NSLog(@"I4Oa0YNZ6wimUW2JERcBk1htlVxToKzrXLFQMCg");
- NSLog(@"aKNVCH6zZ5vixe4G8AcL0f");
- NSLog(@"ST1ons8vH5PgwuJqf0iKtraUOp");
- NSLog(@"yOmCh8FHJNGaoMqe5PXdQUTxpVEI23sfbtjWRgZr");
- NSLog(@"eYirIaMbGhtqBOV4DsgdFvjc3fAxK5PSQR0m2H");
- NSLog(@"kljLKm5PYNCOch6WnizxgFTRtwVJadZM7U4sDvyf");
- NSLog(@"ry1KtVqF8x2ma7RzBU4YONbsjpSGnufd9WQ30w6");
- NSLog(@"DKM8X5awRfuo");
- NSLog(@"50ad8qcyrD32P9RMs");
- NSLog(@"fd3q5WjIhb6wO0tUZRYCigxpv8u");
- NSLog(@"wgHeraRxsil1FMUGvQu05Wm7Nh4yAfDoVBjS2Z");
- NSLog(@"ripQK9xuzB0Gh");
- NSLog(@"fZiqtGLIB02d");
- NSLog(@"XDOcBCdHf1UbvRLek");
- }
- @end
|