// // HighlightDimmableButton.swift // Mastodon // // Created by MainasuK Cirno on 2021-2-23. // import UIKit final class HighlightDimmableButton: UIButton { var expandEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) override init(frame: CGRect) { super.init(frame: frame) _init() } required init?(coder: NSCoder) { super.init(coder: coder) _init() } override func point(inside point: CGPoint, with event: UIEvent?) -> Bool { return bounds.inset(by: expandEdgeInsets).contains(point) } override var isHighlighted: Bool { didSet { alpha = isHighlighted ? 0.6 : 1 } } } extension HighlightDimmableButton { private func _init() { adjustsImageWhenHighlighted = false } }