Revision control
Copy as Markdown
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
import UIKit
final class MenuPaddedLabel: UILabel {
var textInsets = UIEdgeInsets(top: 8, left: 12, bottom: 8, right: 12)
override func drawText(in rect: CGRect) {
super.drawText(in: rect.inset(by: textInsets))
}
override var intrinsicContentSize: CGSize {
let size = super.intrinsicContentSize
return CGSize(
width: size.width + textInsets.left + textInsets.right,
height: size.height + textInsets.top + textInsets.bottom
)
}
}