Graphics Programs Reference
In-Depth Information
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
{
// Call the superclass's designated initializer
self = [super initWithNibName:nil
bundle:nil];
if (self) {
// Get the tab bar item
UITabBarItem *tbi = [self tabBarItem];
// Give it a label
[tbi setTitle:@"Time"];
}
return self;
}
Build and run the application. Two labeled tab bar items will appear on the tab bar ( Fig-
ure 7.15 ) .
Figure 7.15 Tab bar items with labels
Now let's add an image for each tab bar. Locate the image files Hypno.png ,
Time.png , Hypno@2x.png , and Time@2x.png in the Resources directory you
downloaded from http://www.bignerdranch.com/solutions/iOSPro-
gramming3ed.zip . Drag these files into HypnoTime 's project navigator and check the
box to copy the files into the project directory. Then, in HypnosisViewControl-
ler.m , edit initWithNibName:bundle: :
- (id)initWithNibName:(NSString *)nibName bundle:(NSBundle *)bundle
{
self = [super initWithNibName:nil
bundle:nil];
if (self) {
UITabBarItem *tbi = [self tabBarItem];
[tbi setTitle:@"Hypnosis"];
// Create a UIImage from a file
// This will use Hypno@2x.png on retina display devices
UIImage *i = [UIImage imageNamed:@"Hypno.png"];
// Put that image on the tab bar item
[tbi setImage:i];
}
return self;
}
 
Search WWH ::




Custom Search