Created
October 9, 2018 11:06
-
-
Save novinfard/5f38ffd566ffd579c59da1b80bb716df to your computer and use it in GitHub Desktop.
[Padded Label]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import UIKit | |
| class UIPaddedLabel: UILabel { | |
| var padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) | |
| public override func drawText(in rect: CGRect) { | |
| super.drawText(in: UIEdgeInsetsInsetRect(rect, padding)) | |
| } | |
| public override var intrinsicContentSize: CGSize { | |
| let size = super.intrinsicContentSize | |
| return CGSize(width: size.width + padding.left + padding.right, | |
| height: size.height + padding.top + padding.bottom) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment