Slide 18
Slide 18 text
$VTUPN$PMPS
w ίʔυͰఆٛ
w "TTFU$BUBMPHͰఆٛ
extension UIColor {
// you provide creates a new color object based on the traits in the
provided trait collection.
@available(iOS 13.0, *)
public init(dynamicProvider: @escaping (UITraitCollection) -> UIColor)
}
extension UIColor {
static let dynamicColor = UIColor { (traitCollection:
UITraitCollection) -> UIColor in
if traitCollection.userInterfaceStyle == .dark {
return .white
} else {
return .black
}
}
}