extension UIView { /// /// Loads a view from nib. /// /// Please note that if you are assigning directly to an optinonal or unwrapped /// optional you have to specify `name` of the nib. /// class func loadFromNib(_ name: String = String(describing: T.self), owner: AnyObject? = nil, options: [AnyHashable: Any]? = nil, bundle: Bundle? = Bundle.main) -> T { return UINib(nibName: name, bundle: bundle).instantiate(withOwner: owner, options: options).first as! T } class func loadFromNib(_ name: String = String(describing: T.self), index: Int) -> T { return UINib(nibName: name, bundle: nil).instantiate(withOwner: nil, options: nil)[index] as! T } }