Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

boyplunder

macrumors regular
Original poster
Sep 8, 2008
165
0
UK
I have recently put some time into learning how to add a toolbar to the navcontroller using programming instead of IB.

I added a button to show an about view, which works well, but can't figure out how to add a label on the toolbar. I started with the example code Apple gives, just to see it in action:

CGRect labelFrame = CGRectMake(150.0, 340.0, 150.0, 30.0);
UILabel *label = [[UILabel alloc] initWithFrame:labelFrame];
[label setFont:[UIFont systemFontOfSize:14]];
label.textAlignment = UITextAlignmentLeft;
[label setText:mad:"App Name"];
label.textColor = [UIColor redColor];
label.backgroundColor = [UIColor clearColor];
[self.view addSubview:label];

To those in the know, this obviously adds the label to the list in the nav controller, not the toolbar. This means the label is underneath the toolbar. I can see it must have to be added to the toolbar controller, a level up, but can't see how or where to put it.

Any pointers?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.