Skip to content

Instantly share code, notes, and snippets.

View omeileo's full-sized avatar
💭
`$ brew creating something amazing`

Jase-Omeileo West omeileo

💭
`$ brew creating something amazing`
View GitHub Profile
@NikolaiRuhe
NikolaiRuhe / NRLabel.swift
Last active April 9, 2020 05:01
A UILabel subclass that adds padding around the text and handles layout properly.
import UIKit
class NRLabel : UILabel {
var textInsets = UIEdgeInsets.zero {
didSet { invalidateIntrinsicContentSize() }
}
override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
let insetRect = UIEdgeInsetsInsetRect(bounds, textInsets)