// // UpNavigationBar.m // Eat // // Created by chenan on 13-10-29. // Copyright (c) 2013年 user. All rights reserved. // #import "UpNavigationBar.h" UIViewController * control; @implementation UINavigationBar (UINavigationBarCategory) -(void)setBackgroundImage:(UIViewController*)_view BackgroundImage:(UIImage*)image LeftSel:(SEL)leftSel RightSel:(SEL)rightSel CenterSel:(SEL)centerSel Title:(NSString *)title TempKind:(int)tempkind{ _view.navigationItem.hidesBackButton=YES; UIView *subviews=(UIView *)[self viewWithTag:NavBarSubviews]; if (subviews!=nil) { NSArray *views=[subviews subviews]; for (UIView *view in views) { [view removeFromSuperview]; } }else { UIView *view=[[UIView alloc]init]; view.frame=CGRectMake(0,0,self.frame.size.width,30); subviews=view; subviews.autoresizesSubviews=YES; subviews.tag=NavBarSubviews; [self addSubview:subviews]; [subviews release]; } if (tempkind==1) { subviews.backgroundColor=[UIColor colorWithRed:253.0f/255 green:133.0f/255 blue:54.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) RECT5:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) FontName:@"ArialMT" Red:255 green:255 blue:255 FontSize:20 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; [FuncPublic InstanceButton:@"Sistem_back" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) RECT5:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) AddView:subviews ViewController:_view SEL_:leftSel Kind:2 TAG:-1]; UIButton *public= [FuncPublic InstanceButton:@"" Ect:@"" FileName2:@"" Ect2:@"" RECT:CGRectMake(240, [FuncPublic IosPosChange],74, 44) RECT5:CGRectMake(240, [FuncPublic IosPosChange],74, 44) AddView:subviews ViewController:_view SEL_:rightSel Kind:1 TAG:-1]; [public setTitle:@"清空" forState:UIControlStateNormal]; [public setTitleColor:[UIColor colorWithRed:255.0f/255 green:255.0f/255 blue:255.0f/255 alpha:1.0f] forState:UIControlStateNormal]; public.titleLabel.font=[UIFont fontWithName:@"ArialMT" size:16]; }else if(tempkind==2) { subviews.backgroundColor=[UIColor colorWithRed:255.0f/255 green:97.0f/255 blue:102.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) RECT5:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) FontName:@"ArialMT" Red:255 green:255 blue:255 FontSize:20 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; [FuncPublic InstanceButton:@"Sistem_back" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) RECT5:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) AddView:subviews ViewController:_view SEL_:leftSel Kind:2 TAG:-1]; }else if(tempkind==6) { subviews.backgroundColor=[UIColor colorWithRed:115.0f/255 green:210.0f/255 blue:76.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) RECT5:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) FontName:@"ArialMT" Red:255 green:255 blue:255 FontSize:20 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; [FuncPublic InstanceButton:@"Sistem_back" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) RECT5:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) AddView:subviews ViewController:_view SEL_:leftSel Kind:2 TAG:-1]; }else if(tempkind==7) { subviews.backgroundColor=[UIColor colorWithRed:0.0f/255 green:195.0f/255 blue:246.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) RECT5:CGRectMake((DEVW-240)/2, [FuncPublic IosPosChange]+ 7, 240, 30) FontName:@"ArialMT" Red:255 green:255 blue:255 FontSize:20 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; [FuncPublic InstanceButton:@"Sistem_back" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) RECT5:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) AddView:subviews ViewController:_view SEL_:leftSel Kind:2 TAG:-1]; }else if(tempkind==3) { subviews.backgroundColor=[UIColor colorWithRed:115.0f/255 green:210.0f/255 blue:76.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake((DEVW-240)/2, 0, 240, 30) RECT5:CGRectMake((DEVW-240)/2, 0, 240, 30) FontName:@"ArialMT" Red:255 green:255 blue:255 FontSize:20 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; [FuncPublic InstanceButton:@"Sistem_back" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(0, 0, 30, 30) RECT5:CGRectMake(0,0, 30, 30) AddView:subviews ViewController:_view SEL_:leftSel Kind:2 TAG:-1]; }else if(tempkind==1) { subviews.backgroundColor=[UIColor colorWithRed:244.0f/255 green:244.0f/255 blue:244.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake(40, [FuncPublic IosPosChange]+ 7, 240, 30) RECT5:CGRectMake(40, [FuncPublic IosPosChange]+ 7, 240, 30) FontName:@"Arial-BoldMT" Red:38 green:136 blue:194 FontSize:18 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; }else if(tempkind==4) { subviews.backgroundColor=[UIColor colorWithRed:0.0f/255 green:195.0f/255 blue:246.0f/255 alpha:1.0f]; [FuncPublic InstanceLabel:title RECT:CGRectMake(40, [FuncPublic IosPosChange]+ 7, 240, 30) RECT5:CGRectMake(40, [FuncPublic IosPosChange]+ 7, 240, 30) FontName:@"Arial-BoldMT" Red:38 green:136 blue:194 FontSize:18 Target:subviews Lines:0 TAG:-1 Ailgnment:1]; [FuncPublic InstanceButton:@"Sistem_back" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) RECT5:CGRectMake(0, [FuncPublic IosPosChange], 44, 44) AddView:subviews ViewController:_view SEL_:leftSel Kind:2 TAG:-1]; [FuncPublic InstanceButton:@"CollectInfoBT" Ect:@"png" FileName2:@"" Ect2:@"" RECT:CGRectMake(320-44, [FuncPublic IosPosChange], 44, 44) RECT5:CGRectMake(320-44, [FuncPublic IosPosChange], 44, 44) AddView:subviews ViewController:_view SEL_:rightSel Kind:2 TAG:-1]; } } -(void)textDown { UITextField * search=(UITextField *)[self viewWithTag:PublicTag+1]; [search resignFirstResponder]; } #pragma mark - textfield delegate - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; if (textField.text.length<1) { [FuncPublic ShowAlert:@"搜索内容不能为空"]; return YES; } [control performSelector:@selector(dosearch:) withObject:textField.text]; return YES; } @end