//Create a navigation barUinavigationbar *navigationbar=[[uinavigationbar Alloc] Initwithframe:cgrectmake (0,0, the, -)]; //Create a navigation bar collectionUinavigationitem *navigationitem=[[Uinavigationitem alloc] initwithtitle:nil]; //Create a button to the left of a navigation barUibarbuttonitem *leftbutton=[[uibarbuttonitem Alloc] Initwithtitle:@"left"style:uibarbuttonitemstylebordered target:self Action: @selector (dosomething)]; //Create a button to the right of a navigation barUibarbuttonitem *rightbutton=[[uibarbuttonitem Alloc] Initwithtitle:@"Right"style:uibarbuttonitemstylebordered target:self Action: @selector (dosomething)]; [Navigationitem settitle:@"Navigation bar"]; //add buttons to the left and right sides of the navigation bar collection[Navigationitem Setleftbarbuttonitem:leftbutton]; [Navigationitem Setrightbarbuttonitem:rightbutton]; //Add a navigation bar collection to the navigation bar[Navigationbar Pushnavigationitem:navigationitem Animated:no]; //View Add navigation bar[Self.view Addsubview:navigationbar];
The results of the operation are as follows:
IOS Navigation Bar