Kurdtvs-Live-Kurdish-TV-Kur.../MastodonSDK/Sources/MastodonUI/View/Button/HighlightDimmableButton.swift

41 lines
880 B
Swift
Raw Normal View History

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