Last active
January 22, 2025 02:34
-
-
Save nitin-agam/3ec783853797fe06dbea369f3a7c347e to your computer and use it in GitHub Desktop.
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
extension UILabel { | |
static func spaceLabel() -> UILabel { | |
let spacingLabel = UILabel() | |
spacingLabel.frame = CGRect(x: 0, y: 0, width: 150, height: 50) | |
spacingLabel.textColor = .white | |
spacingLabel.textAlignment = .center | |
spacingLabel.font = UIFont.boldSystemFont(ofSize: 18) | |
spacingLabel.text = "LIKE ME" | |
spacingLabel.backgroundColor = .red | |
return spacingLabel | |
} | |
// adding space between each characters | |
func addCharacterSpacing(kernValue: Double = 3) { | |
if let labelText = text, labelText.isEmpty == false { | |
let attributedString = NSMutableAttributedString(string: labelText) | |
attributedString.addAttribute(.kern, | |
value: kernValue, | |
range: NSRange(location: 0, length: attributedString.length - 1)) | |
attributedText = attributedString | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment