I have the code likes, in the title bar I am having 3 buttons, left search button, right camera button and option button, in between I am having title.
What I want to do is, I want to display the title centered between the search button and Camera button, can anyone help me how to do this.
//Left Button
UIBarButtonItem *leftSearch = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"btn_search"] style:UIBarButtonItemStyleBordered target:self action:@selector(gotoSearch)];
leftSearch.imageInsets = UIEdgeInsetsMake(0, -5.0f, 0, 0);
[leftSearch setTintColor:[UIColor whiteColor]];
/////////
//Right Button -- First Camera
UIBarButtonItem *rightCamera = [[UIBarButtonItem alloc]
initWithImage:[UIImage imageNamed:@"icon_camera"]
style:UIBarButtonItemStyleBordered
target:self
action:@selector(gotoPhotoGallery)];
[rightCamera setTintColor:[UIColor whiteColor]];
rightCamera.imageInsets = UIEdgeInsetsMake(0, 0, 0, -59.0f);
///////////////////
//Right second Button -- for options menu
UIBarButtonItem *rightMenu = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"header_option"] style:UIBarButtonItemStyleBordered target:self action:@selector(gotoPhotoGallery)];
[rightMenu setTintColor:[UIColor whiteColor]];
rightMenu.imageInsets = UIEdgeInsetsMake(0, 0, 0, 5.0f);
///////////////////
NSArray *buttons = @[rightMenu, rightCamera];
self.navigationItem.rightBarButtonItems = buttons;
[[self navigationItem] setLeftBarButtonItem:leftSearch];
//Title Label
UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"Museo Sans" size:20];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = LoginUserName;
self.navigationItem.titleView = label;
[label sizeToFit];
Aucun commentaire:
Enregistrer un commentaire