Last active
April 3, 2018 20:40
-
-
Save raonivaladares/dfb148ab6be875b036fcbf3e7ea07bd6 to your computer and use it in GitHub Desktop.
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
import UIKit | |
final class UILabelFactory { | |
private let label: UILabel | |
private let defultFontSize: CGFloat = 20 | |
// MARK: - Inits | |
init(text: String) { | |
label = UILabel() | |
label.textAlignment = .center | |
label.text = text | |
label.font = label.font.withSize(defultFontSize) | |
label.translatesAutoresizingMaskIntoConstraints = false | |
} | |
// MARK: - Public methods | |
func fontSize(of size: CGFloat) -> Self { | |
label.font = label.font.withSize(size) | |
return self | |
} | |
func textColor(with color: UIColor) -> Self { | |
label.textColor = color | |
return self | |
} | |
func numberOf(lines: Int) -> Self { | |
label.numberOfLines = lines | |
return self | |
} | |
func build() -> UILabel { | |
return label | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment