Customizable
public protocol Customizable
Describes a protocol to enable objects to be customized, typically chained at initialization time.
Inspired by: https://github.com/devxoul/Then
-
customize(_:)
Extension methodSet properties on
self
with a closure.Example:
let label = UILabel(frame: .zero).customize { $0.text = "Text goes here..." $0.textColor = .black $0.sizeToFit() $0.center = view.center $0.add(toSuperview: $0) }
Declaration
Swift
@discardableResult public func customize(_ customize: (Self) -> Void) -> Self
Parameters
customize
A closure, performing the customization.
Return Value
self