Assign xib to the UIView in Swift

for Swift 4 extension UIView { class func loadFromNibNamed(nibNamed: String, bundle: Bundle? = nil) -> UIView? { return UINib( nibName: nibNamed, bundle: bundle ).instantiate(withOwner: nil, options: nil)[0] as? UIView } } for Swift 3 You could create an extension on UIView: extension UIView { class func loadFromNibNamed(nibNamed: String, bundle: NSBundle? = nil) -> UIView? { … Read more