UIView.swift 476 B

1234567891011121314151617181920
  1. //
  2. // UIView.swift
  3. // Gasetizko Margolariak
  4. //
  5. // Created by Yuji Hato on 11/5/15.
  6. // Copyright © 2015 Yuji Hato. All rights reserved.
  7. //
  8. import UIKit
  9. extension UIView {
  10. class func loadNib<T: UIView>(viewType: T.Type) -> T {
  11. let className = String.className(viewType)
  12. return NSBundle(forClass: viewType).loadNibNamed(className, owner: nil, options: nil).first as! T
  13. }
  14. class func loadNib() -> Self {
  15. return loadNib(self)
  16. }
  17. }