Created
June 25, 2019 11:10
-
-
Save damodarnamala/0c3869e975363aebdf491e459ec39572 to your computer and use it in GitHub Desktop.
Writing the extensions like rx
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
// Extention | |
extension UILabel { | |
func color(_ color: UIColor)->UILabel { | |
self.textColor = color | |
return self | |
} | |
func font(_ name: String = "Helvetica ", size: CGFloat = 10)->UILabel { | |
self.font = UIFont(name: name, size: size) | |
return self | |
} | |
} | |
// Ussage | |
let label = UILabel() | |
label | |
.color(UIColor.red) | |
.font("Helvetica", size: 12) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment