Açıklama Yok

FKAppearanceUtil.m 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. //
  2. // FKAppearanceUtil.m
  3. // FirstLink
  4. //
  5. // Created by ascii on 15/8/24.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "FKAppearanceUtil.h"
  9. #import "FLImageHelper.h"
  10. #import "FLControllerHelper.h"
  11. #import "UserDefaultManager.h"
  12. #import "GuideViewController.h"
  13. #import "SchemaManager.h"
  14. #import "FKUserFindAuthority.h"
  15. @implementation FKAppearanceUtil
  16. + (void)configAppearance {
  17. [FKAppearanceUtil configNavigationBar];
  18. [FKAppearanceUtil configTextFieldAppearance];
  19. [FKAppearanceUtil configTextViewAppearance];
  20. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
  21. }
  22. + (void)configTabBarController {
  23. UITabBarController *controller = (UITabBarController*)[[UIApplication sharedApplication] keyWindow].rootViewController;
  24. if (![controller isKindOfClass:[UITabBarController class]]) {
  25. controller = [[UITabBarController alloc] init];
  26. }
  27. UITabBarController *tabBarController = (UITabBarController *)controller;
  28. UITabBar *tabBar = tabBarController.tabBar;
  29. tabBar.translucent = NO;
  30. tabBar.backgroundColor = UIColorFromRGB(0xffffff);
  31. NSArray *selectedImageArray;
  32. NSArray *unselectedImageArray;
  33. NSArray *viewControllerNames;
  34. FKUserFindAuthority *userAuthority = [FKUserFindAuthority analysisData];
  35. if ([userAuthority isNeedShowDiscoverView]) {
  36. selectedImageArray = @[@"Alpha3_Home_Highlight", @"Alpha3_Category_Highlight", @"Alpha3_Discover_Highlight", @"Alpha3_Basket_Highlight", @"Alpha3_Mine_Highlight"];
  37. unselectedImageArray = @[@"Alpha3_Home_Normal", @"Alpha3_Category_Normal", @"Alpha3_Discover_Normal", @"Alpha3_Basket_Normal", @"Alpha3_Mine_Normal"];
  38. viewControllerNames = @[@"FKRecommendPageController", @"FKEntireCategoryController", @"FKCircleController", @"FKBasketController", @"HomeViewController"];
  39. } else {
  40. selectedImageArray = @[@"Alpha3_Home_Highlight", @"Alpha3_Category_Highlight", @"Alpha3_Basket_Highlight", @"Alpha3_Mine_Highlight"];
  41. unselectedImageArray = @[@"Alpha3_Home_Normal", @"Alpha3_Category_Normal", @"Alpha3_Basket_Normal", @"Alpha3_Mine_Normal"];
  42. viewControllerNames = @[@"FKRecommendPageController", @"FKEntireCategoryController", @"FKBasketController", @"HomeViewController"];
  43. }
  44. NSMutableArray *naviControllers = [NSMutableArray array];
  45. for (NSString *storyBoardID in viewControllerNames) {
  46. UIViewController *rootController = [[FLControllerHelper currentStoryBoard] instantiateViewControllerWithIdentifier:storyBoardID];
  47. UINavigationController *naviController = [[UINavigationController alloc] initWithRootViewController:rootController];
  48. [naviController setNavigationBarHidden:NO animated:YES];
  49. [naviControllers addObject:naviController];
  50. }
  51. [tabBarController setViewControllers:naviControllers animated:NO];
  52. [[UIApplication sharedApplication] keyWindow].rootViewController = tabBarController;
  53. UITabBarItem *tabBarItem;
  54. UIImage *selectedImage;
  55. UIImage *unselectedImage;
  56. for (int index = 0; index < tabBar.items.count && index < selectedImageArray.count; index++) {
  57. tabBarItem = tabBar.items[index];
  58. selectedImage = [UIImage imageNamed:selectedImageArray[index]];
  59. [tabBarItem setSelectedImage:[selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  60. unselectedImage = [UIImage imageNamed:unselectedImageArray[index]];
  61. [tabBarItem setImage:[unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
  62. [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xffc66e), NSForegroundColorAttributeName,nil]
  63. forState:UIControlStateHighlighted];
  64. [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:UIColorFromRGB(0xffffff), NSForegroundColorAttributeName,nil]
  65. forState:UIControlStateNormal];
  66. }
  67. [[UITabBar appearance] setTintColor:UIColorFromRGB(0xff193a)];
  68. [[UITabBar appearance] setBarTintColor:UIColorFromRGB(0xbf0000)];
  69. [[SchemaManager sharedManager] parser];
  70. }
  71. + (void)configNavigationBar {
  72. [[UINavigationBar appearance] setBarTintColor:UIColorFromRGB(0xffffff)];
  73. [[UINavigationBar appearance] setTintColor:UIColorFromRGB(0x999999)];
  74. [[UINavigationBar appearance] setShadowImage:[UIImage new]];
  75. if([UIDevice currentDevice].systemVersion.floatValue >= 8.0) {
  76. [UINavigationBar appearance].translucent = NO;
  77. }
  78. [[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
  79. [UIColor blackColor], NSForegroundColorAttributeName,
  80. [UIFont systemFontOfSize:18], NSFontAttributeName, nil]];
  81. [[UIBarButtonItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blackColor],
  82. NSFontAttributeName: [UIFont systemFontOfSize:15]
  83. }
  84. forState:UIControlStateNormal];
  85. }
  86. + (void)configTextFieldAppearance {
  87. [[UITextField appearance] setTintColor:UIColorFromRGB(0xff6362)];
  88. }
  89. + (void)configTextViewAppearance {
  90. [[UITextView appearance] setTintColor:UIColorFromRGB(0xff6362)];
  91. }
  92. @end