Created
December 12, 2017 10:05
-
-
Save StevenMasini/b23b6099222aad28ddfe6dff52e2bae8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
extension UIView { | |
/// Load a view from a nib file and return it. | |
/// The Class and the Nib file must have the same name. | |
/// The nib file should contain only one view. | |
/// | |
/// - Returns: The first view found in the nib file. | |
static func loadInstanceFromNib<T: UIView>() -> T? { | |
return Bundle.main.loadNibNamed(String(describing: classForCoder()), owner: self, options: nil)?[0] as? T | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment