
- Removed YuMi/Library/ (138 MB, not tracked) - Removed YuMi/Resources/ (23 MB, not tracked) - Removed old version assets (566 files, not tracked) - Excluded Pods/, xcuserdata/ and other build artifacts - Clean repository optimized for company server deployment
77 lines
2.5 KiB
Objective-C
77 lines
2.5 KiB
Objective-C
//
|
|
// YMTabBar.m
|
|
// YUMI
|
|
//
|
|
// Created by XY on 2023/2/15.
|
|
//
|
|
|
|
#import "XPTabBar.h"
|
|
#import "UIImage+Utils.h"
|
|
#import "YUMIMacroUitls.h"
|
|
#import "DJDKMIMOMColor.h"
|
|
|
|
|
|
CGFloat leftRightSpace = 20.0; // TabBar左右距离
|
|
CGFloat bottomSpace = 29.0; // TabBar离底部距离
|
|
NSInteger itemCount = 5; // tabBarItem的数量
|
|
|
|
@interface XPTabBar()
|
|
|
|
|
|
|
|
@end
|
|
|
|
@implementation XPTabBar
|
|
|
|
- (instancetype)initWithFrame:(CGRect)frame {
|
|
self = [super initWithFrame:frame];
|
|
if(self) {
|
|
|
|
self.backgroundColor = [UIColor whiteColor];
|
|
// 去除顶部横线
|
|
[self setBackgroundImage:[UIImage new]];
|
|
[self setShadowImage:[UIImage new]];
|
|
|
|
if (@available(iOS 15.0, *)) {
|
|
UITabBarAppearance *bar = [UITabBarAppearance new];
|
|
bar.backgroundColor = [UIColor redColor];
|
|
bar.backgroundEffect = nil;
|
|
// 隐藏细线
|
|
[bar configureWithTransparentBackground];
|
|
bar.stackedLayoutAppearance.selected.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[DJDKMIMOMColor confirmButtonGradientEndColor]};
|
|
bar.stackedLayoutAppearance.normal.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:10],NSForegroundColorAttributeName:[DJDKMIMOMColor secondTextColor]};
|
|
self.scrollEdgeAppearance = bar;
|
|
self.standardAppearance = bar;
|
|
} else {
|
|
self.backgroundColor = [UIColor clearColor];
|
|
self.shadowImage = nil;
|
|
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor confirmButtonGradientEndColor]} forState:UIControlStateSelected];
|
|
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[DJDKMIMOMColor secondTextColor]} forState:UIControlStateNormal];
|
|
}
|
|
self.translucent = YES;
|
|
}
|
|
return self;
|
|
}
|
|
|
|
- (void)layoutSubviews {
|
|
[super layoutSubviews];
|
|
// 重设tabBar的位置
|
|
self.frame = CGRectMake(0, KScreenHeight- kTabBarHeight, KScreenWidth, kTabBarHeight);
|
|
|
|
// 设置其他tabbarbtn的frame
|
|
CGFloat tabBarButtonW = (KScreenWidth-leftRightSpace*2)/itemCount;
|
|
CGFloat tabBarButtonIndex = 0;
|
|
for (UIView *child in self.subviews) {
|
|
Class class = NSClassFromString(@"UITabBarButton");
|
|
if ([child isKindOfClass:class]) {
|
|
CGRect frame = CGRectMake(tabBarButtonIndex * tabBarButtonW+leftRightSpace, 17, 34, 34);
|
|
child.frame = frame;
|
|
tabBarButtonIndex ++;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@end
|