Skip to content

Instantly share code, notes, and snippets.

@chrishannah
chrishannah / InsetLabel.swift
Last active March 12, 2022 14:01
A simple subclass of UILabel that allows you to add content insets to pad the content.
import UIKit
class InsetLabel: UILabel {
var contentInsets = UIEdgeInsets.zero
override func drawText(in rect: CGRect) {
let insetRect = UIEdgeInsetsInsetRect(rect, contentInsets)
super.drawText(in: insetRect)
}