Created
April 1, 2023 17:19
-
-
Save kelvinfok/418687f02175fa4214c9df8d724b717b to your computer and use it in GitHub Desktop.
UIKit UILabel Builder Pattern Extension
This file contains 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 { | |
func resizable() -> Self { | |
translatesAutoresizingMaskIntoConstraints = false | |
return self | |
} | |
func text(_ text: String) -> Self { | |
self.text = text | |
return self | |
} | |
func align(_ alignment: NSTextAlignment) -> Self { | |
textAlignment = alignment | |
return self | |
} | |
func font(_ font: UIFont) -> Self { | |
self.font = font | |
return self | |
} | |
func textColor(_ color: UIColor) -> Self { | |
self.textColor = color | |
return self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment