Last active
November 10, 2021 12:00
-
-
Save maximbilan/e87e84b3968260a31184 to your computer and use it in GitHub Desktop.
Swift 1.2 Simple extension for loading UIView with XIB
This file contains 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 NSBundle.mainBundle().loadNibNamed(NSStringFromClass(viewType).pathExtension, owner: nil, options: nil).first as! T | |
} | |
public class func instantiateFromNib() -> Self { | |
return instantiateFromNib(self) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment