Last active
November 24, 2015 17:39
-
-
Save abbeyjackson/f7b5699bde02f3d664f2 to your computer and use it in GitHub Desktop.
instantiate a xib / nib in Swift via an extension and add to a VC
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
// | |
// UIView+NibName.swift | |
// DrakeTaxEstimator | |
// | |
// Created by Kalan Stowe on 10/9/15. | |
// Copyright © 2015 DrakeTaxEstimator. All rights reserved. | |
// | |
import UIKit | |
extension UIView { | |
static func newViewWithNib() -> UIView { | |
let className = NSStringFromClass(self).componentsSeparatedByString(".").last! | |
let viewXib = NSBundle(forClass: self).loadNibNamed(className, owner: nil, options: nil) | |
return viewXib.first as! UIView | |
} | |
} |
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
let footer = TaxEstimatorFooterView.newViewWithNib() as? TaxEstimatorFooterView |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment