IOS TabBar 텍스트메뉴
Posted by Albert 3077Day 11Hour 9Min 37Sec ago [2016-11-16]
보통 ios TabbarController 은 이미지 밑에 텍스트 형식으로 기본으로 제공하고 있다.
이번 프로젝트에서는 이미지가 없는 단순 텍스트로 된 메뉴구조로 가게 되어 조금 찾다가
정리하여 여기에 올립니다.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;
UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica" size:15.0], UITextAttributeFont,[UIColor greenColor],NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Helvetica" size:15.0], UITextAttributeFont,[UIColor blackColor],NSForegroundColorAttributeName,nil] forState:UIControlStateSelected];
[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
[[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -14)];
tabBarItem1.title = @"Home";
tabBarItem2.title = @"option";
return YES;
}
이렇게 Delegate의 didFinishLaunchingWithOptions 에 추가하면 된다.