Skip to content

Commit 2a43564

Browse files
committed
change way to Get initialized tabbar if exists.
1 parent a53dbe7 commit 2a43564

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

CYLTabBarController.xcodeproj/xcuserdata/chenyilong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

+19-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
ignoreCount = "0"
2121
continueAfterRunningActions = "No"
2222
filePath = "Example/CYLTabBarControllerConfig.m"
23-
timestampString = "482294547.088128"
23+
timestampString = "482295802.220628"
2424
startingColumnNumber = "9223372036854775807"
2525
endingColumnNumber = "9223372036854775807"
26-
startingLineNumber = "214"
27-
endingLineNumber = "214"
26+
startingLineNumber = "218"
27+
endingLineNumber = "218"
2828
landmarkName = "-dealloc"
2929
landmarkType = "5">
3030
</BreakpointContent>
@@ -45,5 +45,21 @@
4545
landmarkType = "5">
4646
</BreakpointContent>
4747
</BreakpointProxy>
48+
<BreakpointProxy
49+
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
50+
<BreakpointContent
51+
shouldBeEnabled = "Yes"
52+
ignoreCount = "0"
53+
continueAfterRunningActions = "No"
54+
filePath = "Example/CYLTabBarControllerConfig.m"
55+
timestampString = "482295636.508473"
56+
startingColumnNumber = "9223372036854775807"
57+
endingColumnNumber = "9223372036854775807"
58+
startingLineNumber = "179"
59+
endingLineNumber = "179"
60+
landmarkName = "-customizeTabBarSelectionIndicatorImage"
61+
landmarkType = "5">
62+
</BreakpointContent>
63+
</BreakpointProxy>
4864
</Breakpoints>
4965
</Bucket>

Example/CYLTabBarControllerConfig.m

+5-2
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,13 @@ - (void)updateTabBarCustomizationWhenTabBarItemWidthDidUpdate {
174174

175175
- (void)customizeTabBarSelectionIndicatorImage {
176176
//Get Default TabBar Height
177-
UITabBarController *tabBarController = [[UITabBarController alloc] init];
177+
UITabBarController *tabBarController;
178+
tabBarController = [self cyl_tabBarController] ?: [[UITabBarController alloc] init];
178179
CGFloat tabBarHeight = tabBarController.tabBar.frame.size.height;
179180
CGSize selectionIndicatorImageSize = CGSizeMake(CYLTabBarItemWidth, tabBarHeight);
180-
[[self cyl_tabBarController].tabBar setSelectionIndicatorImage:[[self class]
181+
//Get initialized tabbar if exists.
182+
UITabBar *tabBar = [self cyl_tabBarController].tabBar ?: [UITabBar appearance];
183+
[tabBar setSelectionIndicatorImage:[[self class]
181184
imageFromColor:[UIColor yellowColor]
182185
forSize:selectionIndicatorImageSize
183186
withCornerRadius:0]];

0 commit comments

Comments
 (0)