// // NibLoadable.swift // SwiftBilibili // // Created by 罗文 on 2021/1/15. // Copyright © 2021年 罗文. All rights reserved. // import UIKit protocol NibLoadable{} extension NibLoadable where Self : UIView { static func loadFromNib(_ nibname : String? = nil) -> Self { let loadName = nibname == nil ? "\(self)" : nibname! return Bundle.main.loadNibNamed(loadName, owner: nil, options: nil)?.first as! Self } }