CYLTabBarController
CYLTabBarController copied to clipboard
iOS 13, Tabbar顶部的黑线没法自定义。设置ShadowImage、Layer也不行
Base Info for this issue
- Version:Latest Version as here (1.28.3)
- Language of App :Objective-C
- iOS System Version:iOS13
- Prototype(是否是真机):真机模拟器都一样
- Issue Type:Crash、Bug、Enhancement(希望能支持一个新需求)、Q-A
1. How to reproduce the problem.
2. Please help me in this way.
希望能修复iOS13系统下,tabbar顶部黑线问题,能实现自定义颜色,类似iOS12及以下的效果
3. Here is a Demo.
4. Here is my Debug log
@ChenYilong 麻烦楼主看下这问题
控制器对象调用一下这个方法就行了 hideTabBarShadowImageView
这样就完全去掉顶部的分割线了。 不是想要的效果呀
那还不简单啊,先完全去掉,想要什么样的线自己写个view不就行了。😀
先去掉,然后自己写一个线添加上去。
这。。。不太合适吧。 那还不如直接把tabbar都用view自定义了。 貌似iOS13之后就没法遍历tabbar的shadowiamge了
达到最终要的效果并且不影响任何其他。难道还不行?
不太规范。,,
现在的程序员基本都是搬砖。为了实现效果都在留坑。完成任务才是首位。这就是现实。
iOS 13 tabbar添加了一个新属性 UITabBarAppearance 可以在这里设置
这个不行吧,我看了这个都是tabbar item的属性,还是不能像以前一样修改顶部线条颜色问题
if (@available(iOS 13.0, *)) {
UITabBarAppearance *standardAppearance = [[UITabBarAppearance alloc] init];
UITabBarItemAppearance *inlineLayoutAppearance = [[UITabBarItemAppearance alloc] init];
[ inlineLayoutAppearance.normal setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:RGB(169, 181, 208)}];
[ inlineLayoutAppearance.selected setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:CclearBlue(1)}];
standardAppearance.stackedLayoutAppearance = inlineLayoutAppearance;
standardAppearance.backgroundColor = [UIColor whiteColor];
standardAppearance.shadowImage = [UIImage imageWithColor:CpaleGrey(1)];
self.tabBar.standardAppearance = standardAppearance;
} else {
// Override point for customization after application launch.
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:RGB(169, 181, 208)} forState:UIControlStateNormal];
// 选中状态的标题颜色
[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:CclearBlue(1)} forState:UIControlStateSelected];
[[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]]];
[[UITabBar appearance] setShadowImage:[UIImage imageWithColor:CpaleGrey(1)]];
}
试下了,可以了。 谢谢大佬
上述方法修改后确实有效,但是修改后普通的tabbar 会比之前位置偏下了,请问下什么情况 @ChenYilong
if (@available(iOS 13.0, *)) { UITabBarAppearance *standardAppearance = [[UITabBarAppearance alloc] init]; UITabBarItemAppearance *inlineLayoutAppearance = [[UITabBarItemAppearance alloc] init]; [ inlineLayoutAppearance.normal setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:RGB(169, 181, 208)}]; [ inlineLayoutAppearance.selected setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:CclearBlue(1)}]; standardAppearance.stackedLayoutAppearance = inlineLayoutAppearance; standardAppearance.backgroundColor = [UIColor whiteColor]; standardAppearance.shadowImage = [UIImage imageWithColor:CpaleGrey(1)]; self.tabBar.standardAppearance = standardAppearance; } else { // Override point for customization after application launch. [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:RGB(169, 181, 208)} forState:UIControlStateNormal]; // 选中状态的标题颜色 [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:10], NSForegroundColorAttributeName:CclearBlue(1)} forState:UIControlStateSelected]; [[UITabBar appearance] setBackgroundImage:[UIImage imageWithColor:[UIColor whiteColor]]]; [[UITabBar appearance] setShadowImage:[UIImage imageWithColor:CpaleGrey(1)]]; }
怎么swift 转化不过来
let inlineLayoutAppearance = UITabBarItemAppearance() inlineLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor : APP_TEXT_GRAY_COLOR,NSAttributedString.Key.font : UIFont.init(name: FONTNAME_REGULAR, size: 10*WPERCENT) as Any] appearance.stackedLayoutAppearance = inlineLayoutAppearance
Swift版本 ⏫
@ZJF-Coder @luoshihui @zhuzhiwen0527 ,我这么设置了确实达到了设置分割线的效果,但是 CYLTabBarItemTitlePositionAdjustment设置的偏移量就失效了,是时机问题不对吗?
我今天刚注意到 13.4.1的手机上用老api,也可以,分割线可以设置成功,13.3的还是有问题
上述方法修改后确实有效,但是修改后普通的tabbar 会比之前位置偏下了,请问下什么情况 @ChenYilong
相同的问题 https://github.com/ChenYilong/CYLTabBarController/issues/437