//
//  UIView+Nib.swift
//  sdk-demo-ios
//
//  Created by Smaato Inc on 02.03.20.
//  Copyright © 2020 Smaato Inc. All rights reserved.
//

import UIKit

extension UIView {
    
    static func instantiateFromNib(name :String? = nil) -> Self? {
    
        func instanceFromNib<T: UIView>(name :String? = nil) -> T? {
            let nibName = name ?? String(describing: self)
            let nib = UINib(nibName: nibName, bundle: .main)
            return nib.instantiate(withOwner: nil, options: nil).first as? T
        }
        
        return instanceFromNib(name: name)
    }
}
