Created
March 13, 2017 16:56
-
-
Save ejmartin504/c43c8a5cbbf83fa1952ae86ff3c394d7 to your computer and use it in GitHub Desktop.
Load view from a nib file
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
import UIKit | |
public extension UIView { | |
public class func instantiateFromNib<T: UIView>(viewType: T.Type) -> T { | |
return Bundle.main.loadNibNamed(String(describing: viewType), owner: nil, options: nil)!.first as! T | |
} | |
public class func instantiateFromNib() -> Self { | |
return instantiateFromNib(viewType: self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment