Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS 13, Tabbar顶部的黑线没法自定义。设置ShadowImage、Layer也不行 #431

Open
quietStefan opened this issue Sep 12, 2019 · 21 comments
Assignees

Comments

@quietStefan
Copy link



Base Info for this issue

  1. Version:Latest Version as here
    (1.28.3)
  2. Language of App :Objective-C
  3. iOS System Version:iOS13
  4. Prototype(是否是真机):真机模拟器都一样
  5. 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


@quietStefan
Copy link
Author

image

@quietStefan
Copy link
Author

@ChenYilong
麻烦楼主看下这问题

@lilinxuan
Copy link

控制器对象调用一下这个方法就行了 hideTabBarShadowImageView

@quietStefan
Copy link
Author

这样就完全去掉顶部的分割线了。
不是想要的效果呀

@lilinxuan
Copy link

那还不简单啊,先完全去掉,想要什么样的线自己写个view不就行了。😀

@lilinxuan
Copy link

先去掉,然后自己写一个线添加上去。

@quietStefan
Copy link
Author

这。。。不太合适吧。
那还不如直接把tabbar都用view自定义了。
貌似iOS13之后就没法遍历tabbar的shadowiamge了

@lilinxuan
Copy link

达到最终要的效果并且不影响任何其他。难道还不行?

@quietStefan
Copy link
Author

不太规范。,,

@lilinxuan
Copy link

现在的程序员基本都是搬砖。为了实现效果都在留坑。完成任务才是首位。这就是现实。

@zhuzhiwen0527
Copy link

iOS 13 tabbar添加了一个新属性 UITabBarAppearance 可以在这里设置

@quietStefan
Copy link
Author

这个不行吧,我看了这个都是tabbar item的属性,还是不能像以前一样修改顶部线条颜色问题

@zhuzhiwen0527
Copy link

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)]];
}

@quietStefan
Copy link
Author

试下了,可以了。
谢谢大佬

@luoshihui
Copy link

image

image

@Lee0820
Copy link

Lee0820 commented Sep 26, 2019

上述方法修改后确实有效,但是修改后普通的tabbar 会比之前位置偏下了,请问下什么情况 @ChenYilong

@Xue765
Copy link

Xue765 commented Nov 20, 2019

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 转化不过来

@ZJF-Coder
Copy link

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版本 ⏫

@Lee0820
Copy link

Lee0820 commented May 3, 2020

@ZJF-Coder @luoshihui @zhuzhiwen0527 ,我这么设置了确实达到了设置分割线的效果,但是 CYLTabBarItemTitlePositionAdjustment设置的偏移量就失效了,是时机问题不对吗?

@Lee0820
Copy link

Lee0820 commented May 4, 2020

我今天刚注意到 13.4.1的手机上用老api,也可以,分割线可以设置成功,13.3的还是有问题

@ChenYilong
Copy link
Owner

上述方法修改后确实有效,但是修改后普通的tabbar 会比之前位置偏下了,请问下什么情况 @ChenYilong

 相同的问题 #437

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants