2021-03-12 07:18:07 +01:00
|
|
|
//
|
|
|
|
// RoundedEdgesButton.swift
|
2021-07-16 10:21:47 +02:00
|
|
|
// MastodonUI
|
2021-03-12 07:18:07 +01:00
|
|
|
//
|
|
|
|
// Created by MainasuK Cirno on 2021-3-12.
|
|
|
|
//
|
|
|
|
|
|
|
|
import UIKit
|
|
|
|
|
2021-07-16 10:21:47 +02:00
|
|
|
open class RoundedEdgesButton: UIButton {
|
2022-01-27 14:23:39 +01:00
|
|
|
|
|
|
|
public var cornerRadius: CGFloat = .zero {
|
|
|
|
didSet {
|
|
|
|
setNeedsDisplay()
|
|
|
|
}
|
|
|
|
}
|
2021-03-12 07:18:07 +01:00
|
|
|
|
2021-07-16 10:21:47 +02:00
|
|
|
open override func layoutSubviews() {
|
2021-03-12 07:18:07 +01:00
|
|
|
super.layoutSubviews()
|
|
|
|
|
|
|
|
layer.masksToBounds = true
|
2022-01-27 14:23:39 +01:00
|
|
|
layer.cornerRadius = cornerRadius > .zero ? cornerRadius : bounds.height * 0.5
|
2021-03-12 07:18:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|