Fix "complementaryColor" color isn't changed after updating the application theme (#496)
This commit is contained in:
@@ -28,12 +28,12 @@ struct SkeletonLayer {
|
||||
self.maskLayer.bounds = holder.definedMaxBounds
|
||||
self.maskLayer.cornerRadius = CGFloat(holder.skeletonCornerRadius)
|
||||
addTextLinesIfNeeded()
|
||||
self.maskLayer.tint(withColors: colors)
|
||||
self.maskLayer.tint(withColors: colors, traitCollection: holder.traitCollection)
|
||||
}
|
||||
|
||||
func update(usingColors colors: [UIColor]) {
|
||||
layoutIfNeeded()
|
||||
maskLayer.tint(withColors: colors)
|
||||
maskLayer.tint(withColors: colors, traitCollection: holder?.traitCollection)
|
||||
}
|
||||
|
||||
func layoutIfNeeded() {
|
||||
|
||||
@@ -15,11 +15,15 @@ import UIKit
|
||||
|
||||
extension CAGradientLayer {
|
||||
|
||||
override func tint(withColors colors: [UIColor]) {
|
||||
override func tint(withColors colors: [UIColor], traitCollection: UITraitCollection?) {
|
||||
skeletonSublayers.recursiveSearch(leafBlock: {
|
||||
self.colors = colors.map { $0.cgColor }
|
||||
if #available(iOS 13.0, tvOS 13, *), let traitCollection = traitCollection {
|
||||
self.colors = colors.map { $0.resolvedColor(with: traitCollection).cgColor }
|
||||
} else {
|
||||
self.colors = colors.map { $0.cgColor }
|
||||
}
|
||||
}) {
|
||||
$0.tint(withColors: colors)
|
||||
$0.tint(withColors: colors, traitCollection: traitCollection)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +39,15 @@ extension CALayer {
|
||||
return sublayers?.filter { $0.name == Constants.skeletonSubLayersName } ?? [CALayer]()
|
||||
}
|
||||
|
||||
@objc func tint(withColors colors: [UIColor]) {
|
||||
@objc func tint(withColors colors: [UIColor], traitCollection: UITraitCollection?) {
|
||||
skeletonSublayers.recursiveSearch(leafBlock: {
|
||||
backgroundColor = colors.first?.cgColor
|
||||
if #available(iOS 13.0, tvOS 13, *), let traitCollection = traitCollection {
|
||||
backgroundColor = colors.first?.resolvedColor(with: traitCollection).cgColor
|
||||
} else {
|
||||
backgroundColor = colors.first?.cgColor
|
||||
}
|
||||
}) {
|
||||
$0.tint(withColors: colors)
|
||||
$0.tint(withColors: colors, traitCollection: traitCollection)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,13 @@ public extension UIColor {
|
||||
}
|
||||
|
||||
var complementaryColor: UIColor {
|
||||
isLight ? darker : lighter
|
||||
if #available(iOS 13, tvOS 13, *) {
|
||||
return UIColor { _ in
|
||||
self.isLight ? self.darker : self.lighter
|
||||
}
|
||||
} else {
|
||||
return isLight ? darker : lighter
|
||||
}
|
||||
}
|
||||
|
||||
var lighter: UIColor {
|
||||
|
||||
Reference in New Issue
Block a user