Djhomeviewcontroller.m
#import "DJHomeViewController.h"#import "DJConstantValue.h"#import "DJNavTopItem.h"@implementationDjhomeviewcontroller-(instancetype) init {uicollectionviewflowlayout*layout =[[Uicollectionviewflowlayout alloc] init]; return[self initwithcollectionviewlayout:layout];}- (void) viewdidload {[Super viewdidload]; Self.collectionView.backgroundColor= Djcolor ( the, the, the); [Self setuprightnavitem]; [Self Setupleftnavitem];}/** Set the right content of the navigation bar*/- (void) Setuprightnavitem {//MapUibarbuttonitem *mapitem = [Uibarbuttonitem itemwithtarget:self action:nil Image:@"Icon_map"Highlighimage:@"icon_map_highlighted"]; MapItem.customView.width= -;//MapItem.customView.backgroundColor = [Uicolor Redcolor]; //SearchUibarbuttonitem *searchitem = [Uibarbuttonitem itemwithtarget:self action:nil Image:@"Icon_search"Highlighimage:@"icon_search_highlighted"]; SearchItem.customView.width= -;//SearchItem.customView.backgroundColor = [Uicolor greencolor];Self.navigationItem.rightBarButtonItems=@[mapitem,searchitem];}/** Set the left content of the navigation bar*/- (void) Setupleftnavitem {Uiimageview*logoview = [[Uiimageview alloc] initwithimage:[uiimage imagenamed:@"Icon_meituan_logo"]]; Uibarbuttonitem*logoitem =[[Uibarbuttonitem alloc] initwithcustomview:logoview]; Djnavtopitem*ITEM01 =[Djnavtopitem item]; Uibarbuttonitem*item1 =[[Uibarbuttonitem alloc] initwithcustomview:item01]; Djnavtopitem*ITEM02 =[Djnavtopitem item]; Uibarbuttonitem*ITEM2 =[[Uibarbuttonitem alloc] initwithcustomview:item02]; Djnavtopitem*ITEM03 =[Djnavtopitem item]; Uibarbuttonitem*ITEM3 =[[Uibarbuttonitem alloc] initwithcustomview:item03]; Self.navigationItem.leftBarButtonItems=@[logoitem,item1,item2,item3]; }@end
Final effect:
Group HD (2)-Set navigation bar content