Created
January 1, 2013 18:05
-
-
Save kechol/4429054 to your computer and use it in GitHub Desktop.
ios app appearance settings example ( iOS5 or later )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // in (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
| if([[UINavigationBar class] respondsToSelector:@selector(appearance)]) { | |
| [[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"navbar.png"] forBarMetrics:UIBarMetricsDefault]; | |
| NSDictionary *titleTextAttr = [NSDictionary dictionaryWithObjectsAndKeys: | |
| [UIColor colorWithWhite:0.21f alpha:1.f], UITextAttributeTextColor, | |
| [UIColor whiteColor], UITextAttributeTextShadowColor, | |
| nil]; | |
| [[UINavigationBar appearance] setTitleTextAttributes:titleTextAttr]; | |
| } | |
| if([[UITabBar class] respondsToSelector:@selector(appearance)]) { | |
| [[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar.png"]]; | |
| [[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"tabbar_item_on.png"]]; | |
| UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController; | |
| UITabBar *tabBar = tabBarController.tabBar; | |
| UITabBarItem *tabBarItem0 = [tabBar.items objectAtIndex:0]; | |
| UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:1]; | |
| UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:2]; | |
| tabBarItem0.title = @"Item0"; | |
| tabBarItem1.title = @"Item1"; | |
| tabBarItem2.title = @"Item2"; | |
| [tabBarItem0 setFinishedSelectedImage:[UIImage imageNamed:@"friends_icon_on.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"friends_icon_off.png"]]; | |
| [tabBarItem1 setFinishedSelectedImage:[UIImage imageNamed:@"home_icon_on.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"home_icon_off.png"]]; | |
| [tabBarItem2 setFinishedSelectedImage:[UIImage imageNamed:@"settings_icon_on.png"] withFinishedUnselectedImage:[UIImage imageNamed:@"settings_icon_off.png"]]; | |
| NSDictionary *highlightedTextAttr = [NSDictionary dictionaryWithObjectsAndKeys: | |
| [UIColor colorWithRed:165/255.0 green:10/255.0 blue:6/255.0 alpha:1.0], UITextAttributeTextColor, | |
| [UIColor whiteColor], UITextAttributeTextShadowColor, | |
| nil]; | |
| [[UITabBarItem appearance] setTitleTextAttributes:highlightedTextAttr forState:UIControlStateHighlighted]; | |
| } | |
| if([[UIBarButtonItem class] respondsToSelector:@selector(appearance)]) { | |
| [[UIBarButtonItem appearance] setBackgroundImage: | |
| [[UIImage imageNamed:@"btn.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 5.0, 0.0, 5.0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; | |
| [[UIBarButtonItem appearance] setBackButtonBackgroundImage: | |
| [[UIImage imageNamed:@"btn_back.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0, 13.0, 0.0, 5.0)] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment