Skip to content

Commit

Permalink
代码优化
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaobs committed Dec 4, 2016
1 parent 5b8df43 commit 215070e
Show file tree
Hide file tree
Showing 52 changed files with 678 additions and 402 deletions.
1 change: 1 addition & 0 deletions JMTabBarKit/JMTabBarKit/JMTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ - (void)setupTabBarController {
navVC.tabBarItem.selectedImage = [UIImage imageNamed:item.selectedImageName];

if (JM_TabBar_IOS7_OR_LATER) {
navVC.tabBarItem.image = [navVC.tabBarItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
navVC.tabBarItem.selectedImage = [navVC.tabBarItem.selectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
}else{
[navVC.tabBarItem setFinishedSelectedImage:navVC.tabBarItem.selectedImage
Expand Down
518 changes: 340 additions & 178 deletions JMTabBarKitTest.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0730"
LastUpgradeVersion = "0810"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -14,26 +14,12 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A2AC5451AE9D5FF00F7E0A2"
BlueprintIdentifier = "1A658B941DF46B0300E265A7"
BuildableName = "JMTabBarKitTest.app"
BlueprintName = "JMTabBarKitTest"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A2AC55E1AE9D5FF00F7E0A2"
BuildableName = "JMTabBarKitTestTests.xctest"
BlueprintName = "JMTabBarKitTestTests"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand All @@ -46,17 +32,27 @@
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A2AC55E1AE9D5FF00F7E0A2"
BlueprintIdentifier = "1A658BAD1DF46B0300E265A7"
BuildableName = "JMTabBarKitTestTests.xctest"
BlueprintName = "JMTabBarKitTestTests"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A658BB81DF46B0300E265A7"
BuildableName = "JMTabBarKitTestUITests.xctest"
BlueprintName = "JMTabBarKitTestUITests"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A2AC5451AE9D5FF00F7E0A2"
BlueprintIdentifier = "1A658B941DF46B0300E265A7"
BuildableName = "JMTabBarKitTest.app"
BlueprintName = "JMTabBarKitTest"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
Expand All @@ -79,7 +75,7 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A2AC5451AE9D5FF00F7E0A2"
BlueprintIdentifier = "1A658B941DF46B0300E265A7"
BuildableName = "JMTabBarKitTest.app"
BlueprintName = "JMTabBarKitTest"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
Expand All @@ -98,7 +94,7 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "1A2AC5451AE9D5FF00F7E0A2"
BlueprintIdentifier = "1A658B941DF46B0300E265A7"
BuildableName = "JMTabBarKitTest.app"
BlueprintName = "JMTabBarKitTest"
ReferencedContainer = "container:JMTabBarKitTest.xcodeproj">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@
<key>JMTabBarKitTest.xcscheme</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>1A2AC5451AE9D5FF00F7E0A2</key>
<key>1A658B941DF46B0300E265A7</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>1A2AC55E1AE9D5FF00F7E0A2</key>
<key>1A658BAD1DF46B0300E265A7</key>
<dict>
<key>primary</key>
<true/>
</dict>
<key>1A658BB81DF46B0300E265A7</key>
<dict>
<key>primary</key>
<true/>
Expand Down
6 changes: 3 additions & 3 deletions JMTabBarKitTest/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// AppDelegate.h
// JMTabBarKitTest
//
// Created by james on 15/4/24.
// Copyright (c) 2015年 james. All rights reserved.
// Created by James on 2016/12/4.
// Copyright © 2016年 James. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "JMTabBarController.h"
#import <JMTabBarKit/JMTabBarKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

Expand Down
48 changes: 27 additions & 21 deletions JMTabBarKitTest/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
// AppDelegate.m
// JMTabBarKitTest
//
// Created by james on 15/4/24.
// Copyright (c) 2015年 james. All rights reserved.
// Created by James on 2016/12/4.
// Copyright © 2016年 James. All rights reserved.
//

#import "AppDelegate.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
#import "ThirdViewController.h"
#import "ViewController.h"
#import "LoginViewController.h"

@interface AppDelegate ()

Expand All @@ -22,54 +22,60 @@ @implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[self setupJMTabBar];

return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}


- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}


- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

#pragma mark - Test
#pragma mark - TabBar
- (void)setupJMTabBar {
NSMutableArray *tabArray = [NSMutableArray array];
JMTabBarItem *item1 = [JMTabBarItem tabBarItemWithTitle:@"首页"
JMTabBarItem *item1 = [JMTabBarItem tabBarItemWithTitle:@"主页"
controllClass:[FirstViewController class]
selectedImageName:@"Tab_Main_Highlight"
unSelectedImageName:@"Tab_Main_Normal"
selectedImageName:@"Tab_Main_Selected"
unSelectedImageName:@"Tab_Main_UnSelected"
selected:true];

[tabArray addObject:item1];

JMTabBarItem *item2 = [JMTabBarItem tabBarItemWithTitle:@"客服"
JMTabBarItem *item2 = [JMTabBarItem tabBarItemWithTitle:@"添加"
controllClass:[SecondViewController class]
selectedImageName:@"Tab_Center_Selected"
unSelectedImageName:@"Tab_Assistant_Normal"
unSelectedImageName:@"Tab_Center_UnSelected"
selected:NO];

[tabArray addObject:item2];

JMTabBarItem *item3 = [JMTabBarItem tabBarItemWithTitle:@"我的"
controllClass:[ThirdViewController class]
selectedImageName:@"Tab_Mine_Highlight"
unSelectedImageName:@"Tab_Mine_Normal"
selectedImageName:@"Tab_Mine_Selected"
unSelectedImageName:@"Tab_Mine_UnSelected"
selected:NO];

[tabArray addObject:item3];
Expand All @@ -78,29 +84,29 @@ - (void)setupJMTabBar {

NSDictionary *unSelectedStyleDic = @{NSFontAttributeName: [UIFont systemFontOfSize:12], NSForegroundColorAttributeName: [UIColor colorWithRed:74.0f/255.0f green:74.0f/255.0f blue:74.0f/255.0f alpha:1.0]};

// 第一种创建方式
_tabBarVC = [[JMTabBarController alloc] initWithTabBarArray:tabArray
selectedTextAttributes:selectedStyleDic
unSelectedTextAttributes:unSelectedStyleDic];
selectedTextAttributes:selectedStyleDic
unSelectedTextAttributes:unSelectedStyleDic];

__weak JMTabBarController *weakTabBarVC = _tabBarVC;
_tabBarVC.tabBarShouldSelectBlock = ^(UIViewController * viewController,NSInteger shouldSelectedIndex) {
if (shouldSelectedIndex == 2) {
ViewController *login = [[ViewController alloc] init];
LoginViewController *login = [[LoginViewController alloc] init];
[weakTabBarVC presentViewController:login animated:YES completion:^{

}];

return NO;
}

return YES;
};
self.window.rootViewController = _tabBarVC;
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 5)];
// view.backgroundColor = [UIColor redColor];
// [tabBarVC.tabBar addSubview:view];
// UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 5)];
// view.backgroundColor = [UIColor redColor];
// [tabBarVC.tabBar addSubview:view];
UITabBarItem* tab = [[_tabBarVC.tabBar items] objectAtIndex:1];
tab.badgeValue = @"99+";
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"images" : [
{
"idiom" : "universal",
"filename" : "未标题-1.pdf",
"filename" : "添加3.pdf",
"scale" : "1x"
},
{
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "主页.pdf",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Binary file not shown.
Loading

0 comments on commit 215070e

Please sign in to comment.