Skip to content

Instantly share code, notes, and snippets.

@letatas
Created January 13, 2020 15:46
Show Gist options
  • Save letatas/84159a6f30c8223b757b6cddd125dc3d to your computer and use it in GitHub Desktop.
Save letatas/84159a6f30c8223b757b6cddd125dc3d to your computer and use it in GitHub Desktop.
ReusableXibViews - NibWrapped - v1
/// Property wrapper used to wrapp a view instanciated from a Nib
@propertyWrapper public struct NibWrapped<T: UIView> {
/// Initializer
///
/// - Parameter type: Type of the wrapped view
public init(_ type: T.Type) { }
/// The wrapped value
public var wrappedValue: UIView!
/// The final view
public var unwrapped: T { (wrappedValue as! NibWrapperView<T>).contentView }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment