mastodon-app-ufficiale-ipho.../MastodonSDK/Sources/MastodonUI/View/Button/RoundedEdgesButton.swift

26 lines
495 B
Swift
Raw Normal View History

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