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

v1.27.0 support iOS13 Dark Mode #386

Closed
ChenYilong opened this issue Jun 14, 2019 · 1 comment
Closed

v1.27.0 support iOS13 Dark Mode #386

ChenYilong opened this issue Jun 14, 2019 · 1 comment

Comments

@ChenYilong
Copy link
Owner

ChenYilong commented Jun 14, 2019

enter image description here



CYLTabBarController 【iOS13 Dark Mode版本】v1.27.0 已经发布,更新日志

  • Xcode10、Xcode11均可编译通过,在未安装 Xcode11 情况下,也可以升级到该版本。【建议尽早升级】
  • 本次升级,未修改初始化方式,升级后无缝支持 iOS13 的 Dark Mode 。最新 Demo 给出了代码演示,效果见后文。
  • 重写了 iOS13 为 Dark Mode 所引入的动态 UIColor --- systemColor 系列 ,兼容在 iOS13 以下设备上使用这些API:内部使用RGB方式实现了静态版的 systemColor 系列,用法参照最新 Demo。
  • 在 iOS13 上,适配红点功能:避免红点颜色受 iOS13 TabBarItem 内引入的毛玻璃效果影响。
  • 在 iOS13 上,支持原有版本 API 隐藏 TabBar 顶部分割线(shadowView)。
  • 修复了 Xcode11 控制台输出大量警告的bug。

效果图

原理解析

在 iOS13 上,适配红点功能:避免红点颜色受 iOS13 TabBarItem 内引入的毛玻璃效果影响。

在iOS13上,如果TabBar或者TabBarItem未设置如下几个相关方法:

  • barTintColor
  • setUnselectedItemTintColor
  • setBackgroundImage
  • setBackgroundColor

是否设置过,结构对比图如下:


从图上可以看出:未设置时,系统会给处于未选中(unselected)状态的 TabBarItem 加一个毛玻璃效果,为灰色,以此来充当UnselectedItemTintColor 保证在 Dark Mode 中显得正常。

这个改动会导致:

解决办法:

  • 接入过程中,设置上述几个API
  • CYLTabBarController自动移除这个毛玻璃效果

CYLTabBarController自动移除的逻辑如下:

当 CYLTabBarController 发现有毛玻璃效果,就内部默认设置 setUnselectedItemTintColor ,颜色为未选中 Item 的 Label 颜色,无 label 时取默认值 systemGrayColor


隐藏TabBar顶部分割线的实现,就是在原有基础上把修改ShadowImageView的透明度,改为修改hidden属性。


@ChenYilong ChenYilong changed the title support iOS13 Dark Mode v1.27.0 support iOS13 Dark Mode Jun 14, 2019
@ChenYilong
Copy link
Owner Author

ChenYilong commented Jun 15, 2019

//去除 TabBar 自带的顶部阴影
需要使用 -[CYLTabBarController hideTabBarShadowImageView] 

见README

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

1 participant