diff --git a/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift b/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift index d85d3a8b..d6ae40e1 100644 --- a/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift +++ b/Mastodon/Scene/Root/Sidebar/View/SidebarListContentView.swift @@ -18,7 +18,7 @@ final class SidebarListContentView: UIView, UIContentView { let avatarButton: CircleAvatarButton = { let button = CircleAvatarButton() button.borderWidth = 2 - button.borderColor = UIColor.label.cgColor + button.borderColor = UIColor.label return button }() diff --git a/Mastodon/Scene/Share/View/Button/AvatarButton.swift b/Mastodon/Scene/Share/View/Button/AvatarButton.swift index 9bc87a05..6249ea37 100644 --- a/Mastodon/Scene/Share/View/Button/AvatarButton.swift +++ b/Mastodon/Scene/Share/View/Button/AvatarButton.swift @@ -38,6 +38,18 @@ class AvatarButton: UIControl { avatarImageView.bottomAnchor.constraint(equalTo: bottomAnchor), ]) } + + override func layoutSubviews() { + super.layoutSubviews() + + updateAppearance() + } + + override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + + updateAppearance() + } func updateAppearance() { avatarImageView.alpha = primaryActionState.contains(.highlighted) ? 0.6 : 1.0 diff --git a/Mastodon/Scene/Share/View/Button/CircleAvatarButton.swift b/Mastodon/Scene/Share/View/Button/CircleAvatarButton.swift index 0bc2aeef..74591dda 100644 --- a/Mastodon/Scene/Share/View/Button/CircleAvatarButton.swift +++ b/Mastodon/Scene/Share/View/Button/CircleAvatarButton.swift @@ -9,15 +9,18 @@ import UIKit final class CircleAvatarButton: AvatarButton { - var borderColor: CGColor = UIColor.systemFill.cgColor + @Published var needsHighlighted = false + + var borderColor: UIColor = UIColor.systemFill var borderWidth: CGFloat = 1.0 - override func layoutSubviews() { - super.layoutSubviews() + override func updateAppearance() { + super.updateAppearance() layer.masksToBounds = true layer.cornerRadius = frame.width * 0.5 - layer.borderColor = borderColor + layer.borderColor = borderColor.cgColor layer.borderWidth = borderWidth } + }