Skip to content

Instantly share code, notes, and snippets.

@protspace
Created July 13, 2018 10:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save protspace/63287e4fb86f662112b4f59e4124cc35 to your computer and use it in GitHub Desktop.
Save protspace/63287e4fb86f662112b4f59e4124cc35 to your computer and use it in GitHub Desktop.
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