Created
September 19, 2016 03:06
-
-
Save leilee/c6dd6e46f426031dc30fa5ff3042df62 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
| // MARK: - Load View From `.xib` | |
| extension UINib { | |
| enum Nib: String { | |
| case SettingHeaderView | |
| case FreeAccountFeaturesView | |
| case ProAccountFeaturesView | |
| case EnterpriseAccountFeaturesView | |
| } | |
| convenience init(nib: Nib, bundle: NSBundle? = nil) { | |
| self.init(nibName: nib.rawValue, bundle: bundle) | |
| } | |
| class func nib(nib: Nib, bundle: NSBundle? = nil) -> UINib { | |
| return UINib(nib: nib, bundle: bundle) | |
| } | |
| func instantiateView<T: UIView>() -> T { | |
| guard let view = self.instantiateWithOwner(nil, options: nil)[0] as? T else { | |
| fatalError("Counldn't instantiate view from \(self)") | |
| } | |
| return view | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment