@@ -73,7 +73,7 @@ - (void)layoutSubviews {
73
73
self.tabBarItemWidth = CYLTabBarItemWidth;
74
74
NSArray *sortedSubviews = [self sortedSubviews ];
75
75
self.tabBarButtonArray = [self tabBarButtonFromTabBarSubviews: sortedSubviews];
76
- [self setupSwappableImageViewDefaultOffset :self .tabBarButtonArray[0 ]];
76
+ [self setupTabImageViewDefaultOffset :self .tabBarButtonArray[0 ]];
77
77
if (!CYLExternPlusButton) {
78
78
return ;
79
79
}
@@ -131,11 +131,11 @@ - (void)setTabBarItemWidth:(CGFloat )tabBarItemWidth {
131
131
}
132
132
}
133
133
134
- - (void )setSwappableImageViewDefaultOffset : (CGFloat )swappableImageViewDefaultOffset {
135
- if (swappableImageViewDefaultOffset != 0 .f ) {
136
- [self willChangeValueForKey: @" swappableImageViewDefaultOffset " ];
137
- _swappableImageViewDefaultOffset = swappableImageViewDefaultOffset ;
138
- [self didChangeValueForKey: @" swappableImageViewDefaultOffset " ];
134
+ - (void )setTabImageViewDefaultOffset : (CGFloat )tabImageViewDefaultOffset {
135
+ if (tabImageViewDefaultOffset != 0 .f ) {
136
+ [self willChangeValueForKey: @" tabImageViewDefaultOffset " ];
137
+ _tabImageViewDefaultOffset = tabImageViewDefaultOffset ;
138
+ [self didChangeValueForKey: @" tabImageViewDefaultOffset " ];
139
139
}
140
140
}
141
141
@@ -210,8 +210,7 @@ - (NSArray *)sortedSubviews {
210
210
- (NSArray *)tabBarButtonFromTabBarSubviews : (NSArray *)tabBarSubviews {
211
211
NSMutableArray *tabBarButtonMutableArray = [NSMutableArray arrayWithCapacity: tabBarSubviews.count - 1 ];
212
212
[tabBarSubviews enumerateObjectsUsingBlock: ^(UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
213
- NSString *button = [NSString stringWithFormat: @" UIT%@ arB%@ " , @" abB" , @" utton" ];
214
- if ([obj isKindOfClass: NSClassFromString (button)]) {
213
+ if ([obj cyl_isTabButton ]) {
215
214
[tabBarButtonMutableArray addObject: obj];
216
215
}
217
216
}];
@@ -221,28 +220,26 @@ - (NSArray *)tabBarButtonFromTabBarSubviews:(NSArray *)tabBarSubviews {
221
220
return [tabBarButtonMutableArray copy ];
222
221
}
223
222
224
- - (void )setupSwappableImageViewDefaultOffset : (UIView *)tabBarButton {
223
+ - (void )setupTabImageViewDefaultOffset : (UIView *)tabBarButton {
225
224
__block BOOL shouldCustomizeImageView = YES ;
226
- __block CGFloat swappableImageViewHeight = 0 .f ;
227
- __block CGFloat swappableImageViewDefaultOffset = 0 .f ;
225
+ __block CGFloat tabImageViewHeight = 0 .f ;
226
+ __block CGFloat tabImageViewDefaultOffset = 0 .f ;
228
227
CGFloat tabBarHeight = self.frame .size .height ;
229
228
[tabBarButton.subviews enumerateObjectsUsingBlock: ^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
230
- NSString *label = [NSString stringWithFormat: @" UITa%@ ut%@ " , @" bBarB" , @" tonLabel" ];
231
- if ([obj isKindOfClass: NSClassFromString (label)]) {
229
+ if ([obj cyl_isTabLabel ]) {
232
230
shouldCustomizeImageView = NO ;
233
231
}
234
- swappableImageViewHeight = obj.frame .size .height ;
235
- NSString *imageView = [NSString stringWithFormat: @" UITabB%@ pp%@ " , @" arSwa" , @" ableImageView" ];
236
- BOOL isSwappableImageView = [obj isKindOfClass: NSClassFromString (imageView)];
237
- if (isSwappableImageView) {
238
- swappableImageViewDefaultOffset = (tabBarHeight - swappableImageViewHeight) * 0.5 * 0.5 ;
232
+ tabImageViewHeight = obj.frame .size .height ;
233
+ BOOL isTabImageView = [obj cyl_isTabImageView ];
234
+ if (isTabImageView) {
235
+ tabImageViewDefaultOffset = (tabBarHeight - tabImageViewHeight) * 0.5 * 0.5 ;
239
236
}
240
- if (isSwappableImageView && swappableImageViewDefaultOffset == 0 .f ) {
237
+ if (isTabImageView && tabImageViewDefaultOffset == 0 .f ) {
241
238
shouldCustomizeImageView = NO ;
242
239
}
243
240
}];
244
241
if (shouldCustomizeImageView) {
245
- self.swappableImageViewDefaultOffset = swappableImageViewDefaultOffset ;
242
+ self.tabImageViewDefaultOffset = tabImageViewDefaultOffset ;
246
243
}
247
244
}
248
245
0 commit comments