Skip to content

Commit ab9e124

Browse files
committed
update Demo UI
1 parent 420a64e commit ab9e124

File tree

4 files changed

+42
-43
lines changed

4 files changed

+42
-43
lines changed

CYLTabBarController.xcodeproj/project.pbxproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
9A474B5A1EF03D1B0020D132 /* UITabBarItem+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A474B591EF03D1B0020D132 /* UITabBarItem+CYLTabBarControllerExtention.m */; };
1818
9A474B5D1EF1586C0020D132 /* UIControl+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A474B5C1EF1586C0020D132 /* UIControl+CYLTabBarControllerExtention.m */; };
1919
9A474C0F1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A474C0E1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m */; };
20-
9A7C59902181C39000EDB266 /* HDLTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A7C598E2181C39000EDB266 /* HDLTabBarController.m */; };
20+
9A7C59902181C39000EDB266 /* MainTabBarController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A7C598E2181C39000EDB266 /* MainTabBarController.m */; };
2121
9AC0181B1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AC0181A1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m */; };
2222
9AE667131C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.m in Sources */ = {isa = PBXBuildFile; fileRef = 9AE667121C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.m */; };
2323
9AE942E71BDC933E00354519 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9AE942CB1BDC933E00354519 /* LaunchScreen.xib */; };
@@ -51,8 +51,8 @@
5151
9A474C0D1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+CYLTabBarControllerExtention.h"; sourceTree = "<group>"; };
5252
9A474C0E1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+CYLTabBarControllerExtention.m"; sourceTree = "<group>"; };
5353
9A5B29111D3475BC009E1BEE /* CYLConstants.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CYLConstants.h; sourceTree = "<group>"; };
54-
9A7C598E2181C39000EDB266 /* HDLTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = HDLTabBarController.m; sourceTree = "<group>"; };
55-
9A7C598F2181C39000EDB266 /* HDLTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HDLTabBarController.h; sourceTree = "<group>"; };
54+
9A7C598E2181C39000EDB266 /* MainTabBarController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainTabBarController.m; sourceTree = "<group>"; };
55+
9A7C598F2181C39000EDB266 /* MainTabBarController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainTabBarController.h; sourceTree = "<group>"; };
5656
9AC018191FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CYLPlusDemoChildViewController.h; sourceTree = "<group>"; };
5757
9AC0181A1FE90AA1001EC2D6 /* CYLPlusDemoChildViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CYLPlusDemoChildViewController.m; sourceTree = "<group>"; };
5858
9AE667111C800085001DED12 /* UIViewController+CYLTabBarControllerExtention.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIViewController+CYLTabBarControllerExtention.h"; sourceTree = "<group>"; };
@@ -192,8 +192,8 @@
192192
children = (
193193
9A1559C71CB6D4D300CAB1AF /* AppDelegate.h */,
194194
9A1559C61CB6D4D300CAB1AF /* AppDelegate.m */,
195-
9A7C598F2181C39000EDB266 /* HDLTabBarController.h */,
196-
9A7C598E2181C39000EDB266 /* HDLTabBarController.m */,
195+
9A7C598F2181C39000EDB266 /* MainTabBarController.h */,
196+
9A7C598E2181C39000EDB266 /* MainTabBarController.m */,
197197
9AE942CF1BDC933E00354519 /* Classes */,
198198
9AE942CB1BDC933E00354519 /* LaunchScreen.xib */,
199199
9AE942CD1BDC933E00354519 /* Main.storyboard */,
@@ -316,7 +316,7 @@
316316
9A474B5A1EF03D1B0020D132 /* UITabBarItem+CYLTabBarControllerExtention.m in Sources */,
317317
9AE942F91BDC937F00354519 /* CYLPlusButton.m in Sources */,
318318
9A1559C81CB6D4D300CAB1AF /* AppDelegate.m in Sources */,
319-
9A7C59902181C39000EDB266 /* HDLTabBarController.m in Sources */,
319+
9A7C59902181C39000EDB266 /* MainTabBarController.m in Sources */,
320320
9A474C0F1EEFCCE200560ED1 /* UIView+CYLTabBarControllerExtention.m in Sources */,
321321
9A1559DD1CB6D56500CAB1AF /* CYLMineViewController.m in Sources */,
322322
9AE942FB1BDC937F00354519 /* CYLTabBarController.m in Sources */,

Example/AppDelegate.m

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
#import "AppDelegate.h"
1010
#import "CYLPlusButtonSubclass.h"
11-
#import "HDLTabBarController.h"
11+
#import "MainTabBarController.h"
1212

1313
@interface AppDelegate ()<UITabBarControllerDelegate, CYLTabBarControllerDelegate>
14-
@property (nonatomic, strong) HDLTabBarController *tabBarController;
14+
@property (nonatomic, strong) MainTabBarController *tabBarController;
1515
@property (nonatomic, weak) UIButton *selectedCover;
1616

1717
@end
@@ -26,26 +26,27 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
2626
self.window = [[UIWindow alloc]init];
2727
self.window.frame = [UIScreen mainScreen].bounds;
2828
[CYLPlusButtonSubclass registerPlusButton];
29-
HDLTabBarController *tabBarController = [[HDLTabBarController alloc] init];
29+
MainTabBarController *tabBarController = [[MainTabBarController alloc] init];
3030
[tabBarController hideTabBadgeBackgroundSeparator];
31-
[tabBarController setViewDidLayoutSubViewsBlock:^(CYLTabBarController *tabBarController) {
32-
if ([self cyl_tabBarController].selectedIndex != 0) {
33-
return;
34-
}
35-
static dispatch_once_t onceToken;
36-
UITabBar *tabBar = tabBarController.tabBar;
37-
for (UIControl *control in tabBar.subviews) {
38-
if ([control cyl_isTabButton]) {
39-
dispatch_once(&onceToken, ^{
40-
NSUInteger delaySeconds = 0.2;
41-
dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds * NSEC_PER_SEC));
42-
dispatch_after(when, dispatch_get_main_queue(), ^{
43-
[self setSelectedCoverShow:YES];
44-
});
45-
});
46-
}
47-
}
48-
}];
31+
//添加仿淘宝tabbar,第一个tab选中后有图标覆盖
32+
// [tabBarController setViewDidLayoutSubViewsBlock:^(CYLTabBarController *tabBarController) {
33+
// if ([self cyl_tabBarController].selectedIndex != 0) {
34+
// return;
35+
// }
36+
// static dispatch_once_t onceToken;
37+
// UITabBar *tabBar = tabBarController.tabBar;
38+
// for (UIControl *control in tabBar.subviews) {
39+
// if ([control cyl_isTabButton]) {
40+
// dispatch_once(&onceToken, ^{
41+
// NSUInteger delaySeconds = 0.2;
42+
// dispatch_time_t when = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delaySeconds * NSEC_PER_SEC));
43+
// dispatch_after(when, dispatch_get_main_queue(), ^{
44+
// [self setSelectedCoverShow:YES];
45+
// });
46+
// });
47+
// }
48+
// }
49+
// }];
4950
tabBarController.delegate = self;
5051
self.tabBarController = tabBarController;
5152
[self.window setRootViewController:tabBarController];
@@ -95,7 +96,6 @@ - (void)addOnceScaleAnimationOnView:(UIView *)animationView {
9596
[animationView.layer addAnimation:animation forKey:nil];
9697
}
9798

98-
9999
- (void)customizeInterfaceWithTabBarController:(CYLTabBarController *)tabBarController {
100100
//设置导航栏
101101
[self setUpNavigationBarAppearance];
@@ -162,17 +162,16 @@ - (void)setUpNavigationBarAppearance {
162162

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

172172
return YES;
173173
}
174174

175-
176175
- (void)tabBarController:(UITabBarController *)tabBarController didSelectControl:(UIControl *)control {
177176
UIView *animationView;
178177

Example/HDLTabBarController.h renamed to Example/MainTabBarController.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// HDLTabBarController.h
2+
// MainTabBarController.h
33
// CYLTabBarController
44
//
55
// v1.16.0 Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 15/11/3.
@@ -16,7 +16,7 @@
1616
@interface CYLBaseNavigationController : UINavigationController
1717
@end
1818

19-
@interface HDLTabBarController : CYLTabBarController
19+
@interface MainTabBarController : CYLTabBarController
2020

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

Example/HDLTabBarController.m renamed to Example/MainTabBarController.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
//
2-
// HDLTabBarController.m
2+
// MainTabBarController.m
33
// CYLTabBarController
44
//
55
// v1.16.0 Created by 微博@iOS程序犭袁 ( http://weibo.com/luohanchenyilong/ ) on 10/20/15.
66
// Copyright © 2015 https://github.com/ChenYilong . All rights reserved.
77
//
8-
#import "HDLTabBarController.h"
8+
#import "MainTabBarController.h"
99
#import <UIKit/UIKit.h>
1010

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

32-
@interface HDLTabBarController ()<UITabBarControllerDelegate>
32+
@interface MainTabBarController ()<UITabBarControllerDelegate>
3333

3434
@end
3535

36-
@implementation HDLTabBarController
36+
@implementation MainTabBarController
3737

3838
- (instancetype)init {
3939
if (!(self = [super init])) {
@@ -53,7 +53,7 @@ - (instancetype)init {
5353
context:nil
5454
];
5555
[self customizeTabBarAppearance:tabBarController];
56-
return (self = (HDLTabBarController *)tabBarController);
56+
return (self = (MainTabBarController *)tabBarController);
5757
}
5858

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

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

0 commit comments

Comments
 (0)