Skip to content

Commit

Permalink
update Demo UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenYilong committed Oct 26, 2018
1 parent 420a64e commit ab9e124
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 43 deletions.
12 changes: 6 additions & 6 deletions CYLTabBarController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
9A474B5A1EF03D1B0020D132 /* UITabBarItem+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A474B591EF03D1B0020D132 /* UITabBarItem+CYLTabBarControllerExtention.m */; };
9A474B5D1EF1586C0020D132 /* UIControl+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A474B5C1EF1586C0020D132 /* UIControl+CYLTabBarControllerExtention.m */; };
9A474C0F1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A474C0E1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m */; };
9A7C59902181C39000EDB266 /* HDLTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A7C598E2181C39000EDB266 /* HDLTabBarController.m */; };
9A7C59902181C39000EDB266 /* MainTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A7C598E2181C39000EDB266 /* MainTabBarController.m */; };
9AC0181B1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AC0181A1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m */; };
9AE667131C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AE667121C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.m */; };
9AE942E71BDC933E00354519 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9AE942CB1BDC933E00354519 /* LaunchScreen.xib */; };
Expand Down Expand Up @@ -51,8 +51,8 @@
9A474C0D1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+CYLTabBarControllerExtention.h"; sourceTree = "<group>"; };
9A474C0E1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+CYLTabBarControllerExtention.m"; sourceTree = "<group>"; };
9A5B29111D3475BC009E1BEE /* CYLConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CYLConstants.h; sourceTree = "<group>"; };
9A7C598E2181C39000EDB266 /* HDLTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDLTabBarController.m; sourceTree = "<group>"; };
9A7C598F2181C39000EDB266 /* HDLTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HDLTabBarController.h; sourceTree = "<group>"; };
9A7C598E2181C39000EDB266 /* MainTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainTabBarController.m; sourceTree = "<group>"; };
9A7C598F2181C39000EDB266 /* MainTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainTabBarController.h; sourceTree = "<group>"; };
9AC018191FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CYLPlusDemoChildViewController.h; sourceTree = "<group>"; };
9AC0181A1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CYLPlusDemoChildViewController.m; sourceTree = "<group>"; };
9AE667111C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+CYLTabBarControllerExtention.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -192,8 +192,8 @@
children = (
9A1559C71CB6D4D300CAB1AF /* AppDelegate.h */,
9A1559C61CB6D4D300CAB1AF /* AppDelegate.m */,
9A7C598F2181C39000EDB266 /* HDLTabBarController.h */,
9A7C598E2181C39000EDB266 /* HDLTabBarController.m */,
9A7C598F2181C39000EDB266 /* MainTabBarController.h */,
9A7C598E2181C39000EDB266 /* MainTabBarController.m */,
9AE942CF1BDC933E00354519 /* Classes */,
9AE942CB1BDC933E00354519 /* LaunchScreen.xib */,
9AE942CD1BDC933E00354519 /* Main.storyboard */,
Expand Down Expand Up @@ -316,7 +316,7 @@
9A474B5A1EF03D1B0020D132 /* UITabBarItem+CYLTabBarControllerExtention.m in Sources */,
9AE942F91BDC937F00354519 /* CYLPlusButton.m in Sources */,
9A1559C81CB6D4D300CAB1AF /* AppDelegate.m in Sources */,
9A7C59902181C39000EDB266 /* HDLTabBarController.m in Sources */,
9A7C59902181C39000EDB266 /* MainTabBarController.m in Sources */,
9A474C0F1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m in Sources */,
9A1559DD1CB6D56500CAB1AF /* CYLMineViewController.m in Sources */,
9AE942FB1BDC937F00354519 /* CYLTabBarController.m in Sources */,
Expand Down
57 changes: 28 additions & 29 deletions Example/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

#import "AppDelegate.h"
#import "CYLPlusButtonSubclass.h"
#import "HDLTabBarController.h"
#import "MainTabBarController.h"

@interface AppDelegate ()<UITabBarControllerDelegate, CYLTabBarControllerDelegate>
@property (nonatomic, strong) HDLTabBarController *tabBarController;
@property (nonatomic, strong) MainTabBarController *tabBarController;
@property (nonatomic, weak) UIButton *selectedCover;

@end
Expand All @@ -26,26 +26,27 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window = [[UIWindow alloc]init];
self.window.frame = [UIScreen mainScreen].bounds;
[CYLPlusButtonSubclass registerPlusButton];
HDLTabBarController *tabBarController = [[HDLTabBarController alloc] init];
MainTabBarController *tabBarController = [[MainTabBarController alloc] init];
[tabBarController hideTabBadgeBackgroundSeparator];
[tabBarController setViewDidLayoutSubViewsBlock:^(CYLTabBarController *tabBarController) {
if ([self cyl_tabBarController].selectedIndex != 0) {
return;
}
static dispatch_once_t onceToken;
UITabBar *tabBar = tabBarController.tabBar;
for (UIControl *control in tabBar.subviews) {
if ([control cyl_isTabButton]) {
dispatch_once(&onceToken, ^{
NSUInteger delaySeconds = 0.2;
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds * NSEC_PER_SEC));
dispatch_after(when, dispatch_get_main_queue(), ^{
[self setSelectedCoverShow:YES];
});
});
}
}
}];
//添加仿淘宝tabbar,第一个tab选中后有图标覆盖
// [tabBarController setViewDidLayoutSubViewsBlock:^(CYLTabBarController *tabBarController) {
// if ([self cyl_tabBarController].selectedIndex != 0) {
// return;
// }
// static dispatch_once_t onceToken;
// UITabBar *tabBar = tabBarController.tabBar;
// for (UIControl *control in tabBar.subviews) {
// if ([control cyl_isTabButton]) {
// dispatch_once(&onceToken, ^{
// NSUInteger delaySeconds = 0.2;
// dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds * NSEC_PER_SEC));
// dispatch_after(when, dispatch_get_main_queue(), ^{
// [self setSelectedCoverShow:YES];
// });
// });
// }
// }
// }];
tabBarController.delegate = self;
self.tabBarController = tabBarController;
[self.window setRootViewController:tabBarController];
Expand Down Expand Up @@ -95,7 +96,6 @@ - (void)addOnceScaleAnimationOnView:(UIView *)animationView {
[animationView.layer addAnimation:animation forKey:nil];
}


- (void)customizeInterfaceWithTabBarController:(CYLTabBarController *)tabBarController {
//设置导航栏
[self setUpNavigationBarAppearance];
Expand Down Expand Up @@ -162,17 +162,16 @@ - (void)setUpNavigationBarAppearance {

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController {
[[self cyl_tabBarController] updateSelectionStatusIfNeededForTabBarController:tabBarController shouldSelectViewController:viewController];
if ([viewController.tabBarItem.cyl_tabButton cyl_isTabButton]|| [viewController.tabBarItem.cyl_tabButton cyl_isPlusButton]) {
CGFloat index = [tabBarController.viewControllers indexOfObject:viewController];
BOOL shouldSelectedCoverShow = (index == 0);
NSLog(@"🔴类名与方法名:%@(在第%@行),描述:%@===%@", @(__PRETTY_FUNCTION__), @(__LINE__), tabBarController, @(tabBarController.selectedIndex));
[self setSelectedCoverShow:shouldSelectedCoverShow];
}
//添加仿淘宝tabbar,第一个tab选中后有图标覆盖
// if ([viewController.tabBarItem.cyl_tabButton cyl_isTabButton]|| [viewController.tabBarItem.cyl_tabButton cyl_isPlusButton]) {
// CGFloat index = [tabBarController.viewControllers indexOfObject:viewController];
// BOOL shouldSelectedCoverShow = (index == 0);
// [self setSelectedCoverShow:shouldSelectedCoverShow];
// }

return YES;
}


- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control {
UIView *animationView;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// HDLTabBarController.h
// MainTabBarController.h
// CYLTabBarController
//
// v1.16.0 Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 15/11/3.
Expand All @@ -16,7 +16,7 @@
@interface CYLBaseNavigationController : UINavigationController
@end

@interface HDLTabBarController : CYLTabBarController
@interface MainTabBarController : CYLTabBarController

//@property (nonatomic, copy) NSString *context;

Expand Down
12 changes: 6 additions & 6 deletions Example/HDLTabBarController.m → Example/MainTabBarController.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//
// HDLTabBarController.m
// MainTabBarController.m
// CYLTabBarController
//
// v1.16.0 Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15.
// Copyright © 2015 https://github.com/ChenYilong . All rights reserved.
//
#import "HDLTabBarController.h"
#import "MainTabBarController.h"
#import <UIKit/UIKit.h>

static CGFloat const CYLTabBarControllerHeight = 40.f;
Expand All @@ -29,11 +29,11 @@ - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)ani
#import "CYLMineViewController.h"
#import "CYLSameCityViewController.h"

@interface HDLTabBarController ()<UITabBarControllerDelegate>
@interface MainTabBarController ()<UITabBarControllerDelegate>

@end

@implementation HDLTabBarController
@implementation MainTabBarController

- (instancetype)init {
if (!(self = [super init])) {
Expand All @@ -53,7 +53,7 @@ - (instancetype)init {
context:nil
];
[self customizeTabBarAppearance:tabBarController];
return (self = (HDLTabBarController *)tabBarController);
return (self = (MainTabBarController *)tabBarController);
}

- (NSArray *)viewControllers {
Expand Down Expand Up @@ -157,7 +157,7 @@ - (void)customizeTabBarAppearance:(CYLTabBarController *)tabBarController {
// If your app need support UIDeviceOrientationLandscapeLeft or UIDeviceOrientationLandscapeRight,
// remove the comment '//'
// 如果你的App需要支持横竖屏,请使用该方法移除注释 '//'
// [self updateTabBarCustomizationWhenTabBarItemWidthDidUpdate];
[self updateTabBarCustomizationWhenTabBarItemWidthDidUpdate];

// set the bar shadow image
// This shadow image attribute is ignored if the tab bar does not also have a custom background image.So at least set somthing.
Expand Down

0 comments on commit ab9e124

Please sign in to comment.