//Change the Title Image in navigation bar:
self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"flower.png"]];
//Checking version 6 or 7 for changing background color of navigation bar
NSString *version = [[UIDevice currentDevice] systemVersion];
if ([version floatValue] < 7) {
self.navigationController.navigationBar.barTintColor=[UIColor blackColor];
} else {
self.navigationController.navigationBar.tintColor=[UIColor blackColor];
}
//Hide the back button
[self.navigationItem setHidesBackButton:YES animated:YES];
//Create custom Back button:
UIButton* customBackButton = [UIButton buttonWithType:101];
[customBackButton setTitle:@"Back" forState:UIControlStateNormal];
[customBackButton addTarget:self action:@selector(done:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *myBackButton = [[UIBarButtonItem alloc] initWithCustomView:customBackButton];
self.navigationItem.backBarButtonItem=myBackButton;
//Create Right bar button: (more than one button)
UIBarButtonItem* allFriends = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"frnds.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(allfrnd:)];
UIBarButtonItem* setting = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"options.png"] style:UIBarButtonItemStyleBordered target:self action:@selector(setting)];
self.navigationItem.rightBarButtonItems=@[setting,allFriends];
//Programmatically pushing a root view controller it embedded with navigation controller
ViewController *user=[self.storyboard instantiateViewControllerWithIdentifier:@"user"];
UINavigationController *navigationController = [[UINavigationController alloc]initWithRootViewController:user];
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
No comments:
Post a Comment