UITabBarController에 아이콘 이미지를 넣기 전까지는 어떻게 들어갈지 상상하기 힘듭니다.
그리고 보고 나면 왜 다른 어플들의 모습이 다 비슷비슷한지 다시 한번 느끼게 되는 결과를 얻게 됩니다.
[code]- (void)applicationDidFinishLaunching:(UIApplication *)application {
UITabBarController *tabBarController = [[UITabBarController alloc] init];
UIViewController *leftViewController = [[UIViewController alloc] init];
UIViewController *rightViewController = [[UIViewController alloc] init];
leftViewController.tabBarItem.title = @”LEFT”;
rightViewController.tabBarItem.title = @”RIGHT”;
leftViewController.tabBarItem.image = [UIImage imageNamed:@”test_a_01.png”];
rightViewController.tabBarItem.image = [UIImage imageNamed:@”test_a_01.png”];
NSArray *tabBarItems = [NSArray arrayWithObjects:leftViewController, rightViewController, nil];
[tabBarController setViewControllers:tabBarItems];
[window addSubview:tabBarController.view];
[tabBarController.view release];
[window makeKeyAndVisible];
}[/code]
위에서 사용하는 이미지는 다음과 같이 단순한 흰색의 이미지입니다. 알아보기 쉽게 하기 위해 배경에 회색을 깔았습니다.
선택된 이미지는 광택처리가 된(?) 하늘색 이미지로 바뀌며(자세히 보시면 그림자까지 들어가 있습니다) 비선택된 이미지는 회색으로 처리 되어있습니다.
이제 탭바를 쓴 앱스들의 아이콘이 모두 동일한 이유를 아시겠나요? 실제로 내가 원하는 이미지를 사용할 수 있도록 할수 있는 방법이 있습니다.
drawRect를 재구현 한다거나, 하지만 쉽고 간편하게 이런것을 구현할 수 있다는 점은 그냥 사용하게 만드는 매력을 가지고 있는 것 같습니다.
1108195223.zip