From ab9e124a0622763930808ab3759ea9f568562c4c Mon Sep 17 00:00:00 2001 From: Elon Chan Date: Fri, 26 Oct 2018 13:43:38 +0800 Subject: [PATCH] update Demo UI --- CYLTabBarController.xcodeproj/project.pbxproj | 12 ++-- Example/AppDelegate.m | 57 +++++++++---------- ...BarController.h => MainTabBarController.h} | 4 +- ...BarController.m => MainTabBarController.m} | 12 ++-- 4 files changed, 42 insertions(+), 43 deletions(-) rename Example/{HDLTabBarController.h => MainTabBarController.h} (86%) rename Example/{HDLTabBarController.m => MainTabBarController.m} (97%) diff --git a/CYLTabBarController.xcodeproj/project.pbxproj b/CYLTabBarController.xcodeproj/project.pbxproj index b1ff1afe..a2225358 100644 --- a/CYLTabBarController.xcodeproj/project.pbxproj +++ b/CYLTabBarController.xcodeproj/project.pbxproj @@ -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 */; }; @@ -51,8 +51,8 @@ 9A474C0D1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+CYLTabBarControllerExtention.h"; sourceTree = ""; }; 9A474C0E1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+CYLTabBarControllerExtention.m"; sourceTree = ""; }; 9A5B29111D3475BC009E1BEE /* CYLConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CYLConstants.h; sourceTree = ""; }; - 9A7C598E2181C39000EDB266 /* HDLTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDLTabBarController.m; sourceTree = ""; }; - 9A7C598F2181C39000EDB266 /* HDLTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HDLTabBarController.h; sourceTree = ""; }; + 9A7C598E2181C39000EDB266 /* MainTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainTabBarController.m; sourceTree = ""; }; + 9A7C598F2181C39000EDB266 /* MainTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainTabBarController.h; sourceTree = ""; }; 9AC018191FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CYLPlusDemoChildViewController.h; sourceTree = ""; }; 9AC0181A1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CYLPlusDemoChildViewController.m; sourceTree = ""; }; 9AE667111C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+CYLTabBarControllerExtention.h"; sourceTree = ""; }; @@ -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 */, @@ -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 */, diff --git a/Example/AppDelegate.m b/Example/AppDelegate.m index 603b5193..9c0f2d90 100644 --- a/Example/AppDelegate.m +++ b/Example/AppDelegate.m @@ -8,10 +8,10 @@ #import "AppDelegate.h" #import "CYLPlusButtonSubclass.h" -#import "HDLTabBarController.h" +#import "MainTabBarController.h" @interface AppDelegate () -@property (nonatomic, strong) HDLTabBarController *tabBarController; +@property (nonatomic, strong) MainTabBarController *tabBarController; @property (nonatomic, weak) UIButton *selectedCover; @end @@ -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]; @@ -95,7 +96,6 @@ - (void)addOnceScaleAnimationOnView:(UIView *)animationView { [animationView.layer addAnimation:animation forKey:nil]; } - - (void)customizeInterfaceWithTabBarController:(CYLTabBarController *)tabBarController { //设置导航栏 [self setUpNavigationBarAppearance]; @@ -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; diff --git a/Example/HDLTabBarController.h b/Example/MainTabBarController.h similarity index 86% rename from Example/HDLTabBarController.h rename to Example/MainTabBarController.h index 5b711e13..99889fd2 100644 --- a/Example/HDLTabBarController.h +++ b/Example/MainTabBarController.h @@ -1,5 +1,5 @@ // -// HDLTabBarController.h +// MainTabBarController.h // CYLTabBarController // // v1.16.0 Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 15/11/3. @@ -16,7 +16,7 @@ @interface CYLBaseNavigationController : UINavigationController @end -@interface HDLTabBarController : CYLTabBarController +@interface MainTabBarController : CYLTabBarController //@property (nonatomic, copy) NSString *context; diff --git a/Example/HDLTabBarController.m b/Example/MainTabBarController.m similarity index 97% rename from Example/HDLTabBarController.m rename to Example/MainTabBarController.m index 7c69a955..7368068e 100644 --- a/Example/HDLTabBarController.m +++ b/Example/MainTabBarController.m @@ -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 static CGFloat const CYLTabBarControllerHeight = 40.f; @@ -29,11 +29,11 @@ - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)ani #import "CYLMineViewController.h" #import "CYLSameCityViewController.h" -@interface HDLTabBarController () +@interface MainTabBarController () @end -@implementation HDLTabBarController +@implementation MainTabBarController - (instancetype)init { if (!(self = [super init])) { @@ -53,7 +53,7 @@ - (instancetype)init { context:nil ]; [self customizeTabBarAppearance:tabBarController]; - return (self = (HDLTabBarController *)tabBarController); + return (self = (MainTabBarController *)tabBarController); } - (NSArray *)viewControllers { @@ -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.