Created
July 13, 2018 10:42
-
-
Save protspace/63287e4fb86f662112b4f59e4124cc35 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 | |
class ViewBuilder { | |
private var view = UIView() | |
func frame(_ frame: CGRect) -> ViewBuilder { | |
view.frame = frame | |
return self | |
} | |
func color(_ backgroundColor: UIColor) -> ViewBuilder { | |
view.backgroundColor = backgroundColor | |
return self | |
} | |
func build() -> UIView { | |
return view | |
} | |
} | |
let view = ViewBuilder() | |
.frame(CGRect.zero) | |
.color(.red) | |
.build() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment