Skip to content

Commit

Permalink
BSButton's style updates on light/dark appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
krugerk committed Oct 6, 2024
1 parent fc3423f commit ef2356c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions BeeKit/UI/BSButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,25 @@ public class BSButton : UIButton {

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)

registerForTraitChanges(
[UITraitUserInterfaceLevel.self]) {
(self: Self, previousTraitCollection: UITraitCollection) in
self.resetStyle()
}

self.setUp()
}

override init(frame: CGRect) {
super.init(frame: frame)

registerForTraitChanges(
[UITraitUserInterfaceLevel.self]) {
(self: Self, previousTraitCollection: UITraitCollection) in
self.resetStyle()
}

self.setUp()
}

Expand All @@ -31,6 +45,10 @@ public class BSButton : UIButton {
self.layer.borderWidth = 1
}

private func resetStyle() {
self.tintColor = dynamicTintFillColor
}

private let dynamicTintFillColor = UIColor { traitCollection in
switch traitCollection.userInterfaceStyle {
case .dark:
Expand Down

0 comments on commit ef2356c

Please sign in to comment.