123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- //
- // FKAppearanceUtil.m
- // FirstLink
- //
- // Created by ascii on 15/8/24.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "FKAppearanceUtil.h"
- #import "FLImageHelper.h"
- #import "FLControllerHelper.h"
- #import "UserDefaultManager.h"
- #import "GuideViewController.h"
- #import "SchemaManager.h"
- #import "FKUserFindAuthority.h"
- @implementation FKAppearanceUtil
- + (void)configAppearance {
- [FKAppearanceUtil configNavigationBar];
- [FKAppearanceUtil configTextFieldAppearance];
- [FKAppearanceUtil configTextViewAppearance];
- [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
- }
- + (void)configTabBarController {
- UITabBarController *controller = (UITabBarController*)[[UIApplication sharedApplication] keyWindow].rootViewController;
- if (![controller isKindOfClass:[UITabBarController class]]) {
- controller = [[UITabBarController alloc] init];
- }
- UITabBarController *tabBarController = (UITabBarController *)controller;
- UITabBar *tabBar = tabBarController.tabBar;
- tabBar.translucent = NO;
- tabBar.backgroundColor = UIColorFromRGB(0xffffff);
-
- NSArray *selectedImageArray;
- NSArray *unselectedImageArray;
- NSArray *viewControllerNames;
-
- FKUserFindAuthority *userAuthority = [FKUserFindAuthority analysisData];
-
- if ([userAuthority isNeedShowDiscoverView]) {
- selectedImageArray = @[@"Alpha3_Home_Highlight", @"Alpha3_Category_Highlight", @"Alpha3_Discover_Highlight", @"Alpha3_Basket_Highlight", @"Alpha3_Mine_Highlight"];
- unselectedImageArray = @[@"Alpha3_Home_Normal", @"Alpha3_Category_Normal", @"Alpha3_Discover_Normal", @"Alpha3_Basket_Normal", @"Alpha3_Mine_Normal"];
- viewControllerNames = @[@"FKRecommendPageController", @"FKEntireCategoryController", @"FKCircleController", @"FKBasketController", @"HomeViewController"];
- } else {
- selectedImageArray = @[@"Alpha3_Home_Highlight", @"Alpha3_Category_Highlight", @"Alpha3_Basket_Highlight", @"Alpha3_Mine_Highlight"];
- unselectedImageArray = @[@"Alpha3_Home_Normal", @"Alpha3_Category_Normal", @"Alpha3_Basket_Normal", @"Alpha3_Mine_Normal"];
- viewControllerNames = @[@"FKRecommendPageController", @"FKEntireCategoryController", @"FKBasketController", @"HomeViewController"];
- }
-
- NSMutableArray *naviControllers = [NSMutableArray array];
- for (NSString *storyBoardID in viewControllerNames) {
- UIViewController *rootController = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:storyBoardID];
- UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:rootController];
- [naviController setNavigationBarHidden:NO animated:YES];
- [naviControllers addObject:naviController];
- }
- [tabBarController setViewControllers:naviControllers animated:NO];
- [[UIApplication sharedApplication] keyWindow].rootViewController = tabBarController;
-
-
- UITabBarItem *tabBarItem;
- UIImage *selectedImage;
- UIImage *unselectedImage;
- for (int index = 0; index < tabBar.items.count && index < selectedImageArray.count; index++) {
- tabBarItem = tabBar.items[index];
- selectedImage = [UIImage imageNamed:selectedImageArray[index]];
- [tabBarItem setSelectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- unselectedImage = [UIImage imageNamed:unselectedImageArray[index]];
- [tabBarItem setImage:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
-
- [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xffc66e), NSForegroundColorAttributeName,nil]
- forState:UIControlStateHighlighted];
-
- [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xffffff), NSForegroundColorAttributeName,nil]
- forState:UIControlStateNormal];
- }
-
- [[UITabBar appearance] setTintColor:UIColorFromRGB(0xff193a)];
- [[UITabBar appearance] setBarTintColor:UIColorFromRGB(0xbf0000)];
-
- [[SchemaManager sharedManager] parser];
- }
- + (void)configNavigationBar {
- [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0xffffff)];
- [[UINavigationBar appearance] setTintColor:UIColorFromRGB(0x999999)];
-
- [[UINavigationBar appearance] setShadowImage:[UIImage new]];
- if([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
- [UINavigationBar appearance].translucent = NO;
- }
-
- [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
- [UIColor blackColor], NSForegroundColorAttributeName,
- [UIFont systemFontOfSize:18], NSFontAttributeName, nil]];
- [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor],
- NSFontAttributeName: [UIFont systemFontOfSize:15]
- }
- forState:UIControlStateNormal];
- }
- + (void)configTextFieldAppearance {
- [[UITextField appearance] setTintColor:UIColorFromRGB(0xff6362)];
- }
- + (void)configTextViewAppearance {
- [[UITextView appearance] setTintColor:UIColorFromRGB(0xff6362)];
- }
- @end
|