kingjiajie / JJCollectionViewRoundFlowLayout_Swift

JJCollectionViewRoundFlowLayout_Swift是JJCollectionViewRoundFlowLayout(OC:https://github.com/kingjiajie/JJCollectionViewRoundFlowLayout )的Swift版本,JJCollectionViewRoundFlowLayout可设置CollectionView的BackgroundColor,可根据用户Cell个数计算背景图尺寸,可自定义是否包括计算CollectionViewHeaderView、CollectionViewFootererView或只计算Cells。设置简单,可自定义背景颜色偏移,设置显示方向(竖向、横向)显示,不同Section设置不同的背景颜色,设置Cell的对齐方式,支持左对齐,右对齐,居中。
MIT License
73 stars 13 forks source link

适配暗黑模式有问题 #1

Closed Whaiyan closed 4 years ago

Whaiyan commented 4 years ago

从后台进前台,整块背景颜色有问题。普通模式下显示暗黑模式颜色,暗黑模式下显示正常模式颜色 IMG_6442

kingjiajie commented 4 years ago

从后台进前台,整块背景颜色有问题。普通模式下显示暗黑模式颜色,暗黑模式下显示正常模式颜色 IMG_6442

我这边先看一下是什么情况。

kingjiajie commented 4 years ago

你好,针对这个问题,我已经进行修复了。更新pod版本 - 2.3.1即可。

我在进行测试的时候,使用暗黑模式切换的时候,会根据代码里设置的颜色进行替换了。

具体修复方式如下:

在底色模块JJCollectionReusableView_Swift 里重写traitCollectionDidChange,接收系统对更改显示模式后的刷新操作。

    override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection);
        self.toChangeCollectionReusableViewRoundInfo(myCacheAttr);
    }

在颜色设置时,判断当时需要显示的颜色。(前提是在原本代理里设置颜色的时候支持根据是否暗黑模式进行不同颜色设置)

if #available(iOS 13.0, *) {
     view.layer.backgroundColor = model.backgroundColor?.resolvedColor(with: self.traitCollection).cgColor
     } else {
     // Fallback on earlier versions
      view.layer.backgroundColor = model.backgroundColor?.cgColor;
     };

如果你有其他更好的修复方式或者有其他疑问的话,欢迎回复。😄