Skip to content

Commit

Permalink
v1.2.0 add api for allItemsInTabBarCount, Include plusButton if exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYilong committed Feb 26, 2016
1 parent 12926af commit c204954
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 30 deletions.
2 changes: 1 addition & 1 deletion CYLTabBarController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "CYLTabBarController"
s.version = "1.1.1"
s.version = "1.2.0"
s.summary = "Highly customizable tabBar and tabBarController for iOS"
s.description = "CYLTabBarController is iPad and iPhone compatible. Supports landscape and portrait orientations and can be used inside UINavigationController."
s.homepage = "https://github.com/ChenYilong/CYLTabBarController"
Expand Down
4 changes: 2 additions & 2 deletions CYLTabBarController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,10 @@
9AE942F21BDC937F00354519 /* CYLTabBarController */ = {
isa = PBXGroup;
children = (
9AE942F51BDC937F00354519 /* CYLTabBar.h */,
9AE942F61BDC937F00354519 /* CYLTabBar.m */,
9AE942F71BDC937F00354519 /* CYLTabBarController.h */,
9AE942F81BDC937F00354519 /* CYLTabBarController.m */,
9AE942F51BDC937F00354519 /* CYLTabBar.h */,
9AE942F61BDC937F00354519 /* CYLTabBar.m */,
9AE942F31BDC937F00354519 /* CYLPlusButton.h */,
9AE942F41BDC937F00354519 /* CYLPlusButton.m */,
9AE667111C800085001DED12 /* UIViewController+CYLJumpToOtherTabBarControllerItem.h */,
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions CYLTabBarController/CYLPlusButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
// Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15.
// Copyright © 2015 https://github.com/ChenYilong . All rights reserved.
//
@import Foundation;
#import <UIKit/UIKit.h>

@import UIKit;

@protocol CYLPlusButtonSubclassing

Expand Down
4 changes: 0 additions & 4 deletions CYLTabBarController/CYLPlusButton.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@

UIButton<CYLPlusButtonSubclassing> *CYLExternPushlishButton = nil;

@interface CYLPlusButton ()

@end

@implementation CYLPlusButton

#pragma mark -
Expand Down
4 changes: 1 addition & 3 deletions CYLTabBarController/CYLTabBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// Copyright © 2015 https://github.com/ChenYilong . All rights reserved.
//

#import <UIKit/UIKit.h>
#import "CYLTabBarController.h"
#import "CYLPlusButton.h"
@import UIKit;

@interface CYLTabBar : UITabBar

Expand Down
2 changes: 2 additions & 0 deletions CYLTabBarController/CYLTabBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
//

#import "CYLTabBar.h"
#import "CYLPlusButton.h"
#import "CYLTabBarController.h"

@interface CYLTabBar ()

Expand Down
13 changes: 11 additions & 2 deletions CYLTabBarController/CYLTabBarController.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ static NSString * const CYLTabBarItemSelectedImage = @"tabBarItemSelectedImage";

extern NSUInteger CYLTabbarItemsCount;

#import <UIKit/UIKit.h>
@import UIKit;

@interface CYLTabBarController : UITabBarController

Expand All @@ -27,9 +27,18 @@ extern NSUInteger CYLTabbarItemsCount;
*/
@property (nonatomic, readwrite, copy) IBOutletCollection(NSDictionary) NSArray *tabBarItemsAttributes;

/*!
* Judge if there is plus button.
*/
+ (BOOL)havePlusButton;

/*!
* Include plusButton if exists.
*/
+ (NSUInteger)allItemsInTabBarCount;

- (id<UIApplicationDelegate>)appDelegate;
- (UIWindow *)rootWindow;
+ (BOOL)havePlusButton;

@end

Expand Down
25 changes: 17 additions & 8 deletions CYLTabBarController/CYLTabBarController.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
//

#import "CYLTabBarController.h"

#import "CYLTabBar.h"
#import "CYLPlusButton.h"
#import <objc/runtime.h>

NSUInteger CYLTabbarItemsCount = 0;

@interface UIViewController (CYLTabBarControllerItemInternal)
Expand Down Expand Up @@ -98,6 +99,21 @@ - (void)addOneChildViewController:(UIViewController *)viewController
[self addChildViewController:viewController];
}

+ (BOOL)havePlusButton {
if (CYLExternPushlishButton) {
return YES;
}
return NO;
}

+ (NSUInteger)allItemsInTabBarCount {
NSUInteger allItemsInTabBar = CYLTabbarItemsCount;
if ([CYLTabBarController havePlusButton]) {
allItemsInTabBar += 1;
}
return allItemsInTabBar;
}

- (id<UIApplicationDelegate>)appDelegate {
return [UIApplication sharedApplication].delegate;
}
Expand All @@ -118,13 +134,6 @@ - (UIWindow *)rootWindow {
return result;
}

+ (BOOL)havePlusButton {
if (CYLExternPushlishButton) {
return YES;
}
return NO;
}

@end

#pragma mark - UIViewController+CYLTabBarControllerItem
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2016年 https://github.com/ChenYilong .All rights reserved.
//

#import <UIKit/UIKit.h>
@import UIKit;

@interface UIViewController (CYLJumpToOtherTabBarControllerItem)

Expand Down
11 changes: 4 additions & 7 deletions Example/Classes/CYLTabBarControllerConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ - (CYLTabBarController *)tabBarController {
/**
* 更多TabBar自定义设置:比如:tabBarItem 的选中和不选中文字和背景图片属性、tabbar 背景图片属性
*/
//[[self class] customizeTabBarAppearance:tabBarController];
#warning IF YOU NEED CUSTOMIZE TABBAR APPEARANCE, REMOVE THE COMMENT '//'
// [[self class] customizeTabBarAppearance:tabBarController];
_tabBarController = tabBarController;
}
return _tabBarController;
Expand Down Expand Up @@ -147,12 +148,8 @@ + (void)customizeTabBarAppearance:(CYLTabBarController *)tabBarController {

// Set the dark color to selected tab (the dimmed background)
// TabBarItem选中后的背景颜色
NSUInteger tabBarItemsCount = tabBarController.viewControllers.count;
NSUInteger allItemsInTabBar = tabBarItemsCount;
if ([CYLTabBarController havePlusButton]) {
allItemsInTabBar = tabBarItemsCount +1;
}
[[UITabBar appearance] setSelectionIndicatorImage:[self imageFromColor:[UIColor colorWithRed:26 / 255.0 green:163 / 255.0 blue:133 / 255.0 alpha:1] forSize:CGSizeMake([UIScreen mainScreen].bounds.size.width / (CGFloat)allItemsInTabBar, 49) withCornerRadius:0]];
NSUInteger allItemsInTabBarCount = [CYLTabBarController allItemsInTabBarCount];
[[UITabBar appearance] setSelectionIndicatorImage:[self imageFromColor:[UIColor yellowColor] forSize:CGSizeMake([UIScreen mainScreen].bounds.size.width / allItemsInTabBarCount, 49.f) withCornerRadius:0]];

// set the bar background color
// 设置背景图片
Expand Down

0 comments on commit c204954

Please sign in to comment.