Reputation: 776
The iPhone's default calendar program shows the "<" and text at the same time in the navigator bar.
I want to have image and text simultaneously as well.
How is this implemented in Xcode?
Upvotes: 0
Views: 2443
Reputation: 454
Create a custom button
UIButton *barBt =[[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 44)];
[barBt setImage:[UIImage imageNamed:@"my_image.png"] forState:UIControlStateNormal];
[barBt setTitle:@"MyTitle" forState:UIControlStateNormal];
[barBt addTarget:self action: @selector(pressed:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barItem = [[UIBarButtonItem alloc]init];
[barItem setCustomView:barBt];
self.navigationItem.leftBarButtonItem = barItem;
Upvotes: 5
Reputation: 21805
You can only have image or text inside the UIBarbuttonItem
, the < is added by iOS by default as a back button for the navigation hierarchy.
You have to design the < button in the image itself if you want both image and the < in the barButton.
Upvotes: 3