Update for iOS 17.
This commit is contained in:
@@ -28,6 +28,11 @@ class GradientView: UIImageView
|
||||
self.init(image: nil)
|
||||
self.direction = direction
|
||||
self.colors = colors
|
||||
|
||||
registerForTraitChanges([UITraitUserInterfaceStyle.self]) { [weak self] (traitEnvironment: Self, previousTraitCollection) in
|
||||
self?.image = nil
|
||||
self?.setNeedsLayout()
|
||||
}
|
||||
}
|
||||
|
||||
private func gradientImage(forSize size: CGSize) -> UIImage? {
|
||||
@@ -70,12 +75,4 @@ class GradientView: UIImageView
|
||||
generatedImageSize = bounds.size
|
||||
}
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
super.traitCollectionDidChange(previousTraitCollection)
|
||||
|
||||
// Regenerate image
|
||||
image = nil
|
||||
setNeedsLayout()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,12 +69,14 @@ class ReliefButton: UIButton
|
||||
backgroundView.layer.rasterizationScale = UIScreen.main.scale
|
||||
addSubview(backgroundView)
|
||||
|
||||
traitCollectionDidChange(nil)
|
||||
registerForTraitChanges([UITraitUserInterfaceStyle.self], handler: handleTraitCollectionChange)
|
||||
|
||||
pointerStyleProvider = { (button, pointerEffect, pointerShape) -> UIPointerStyle? in
|
||||
let preview = UITargetedPreview(view: button)
|
||||
return UIPointerStyle(effect: .lift(preview), shape: pointerShape)
|
||||
}
|
||||
|
||||
handleTraitCollectionChange(self, previousCollection: nil)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
@@ -99,7 +101,7 @@ class ReliefButton: UIButton
|
||||
return inverted ? colors.reversed() : colors
|
||||
}
|
||||
|
||||
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
|
||||
private func handleTraitCollectionChange(_ environment: UITraitEnvironment, previousCollection: UITraitCollection?) {
|
||||
setBackgroundInverted(isHighlighted)
|
||||
backgroundView.layer.borderColor = { traitCollection -> UIColor in
|
||||
if traitCollection.userInterfaceStyle == .dark {
|
||||
@@ -107,7 +109,7 @@ class ReliefButton: UIButton
|
||||
} else {
|
||||
return .white
|
||||
}
|
||||
}(traitCollection).cgColor
|
||||
} (traitCollection).cgColor
|
||||
}
|
||||
|
||||
internal func setBackgroundInverted(_ inverted: Bool) {
|
||||
|
||||
Reference in New Issue
Block a user