Skip to content

Instantly share code, notes, and snippets.

@rsaenzi
Last active March 12, 2020 04:25
Show Gist options
  • Save rsaenzi/0c3da9a1f5084c6ac73cee0b501daf33 to your computer and use it in GitHub Desktop.
Save rsaenzi/0c3da9a1f5084c6ac73cee0b501daf33 to your computer and use it in GitHub Desktop.
Util functions for UIViews
//
// UIView+Load.swift
//
// Created by Rigoberto Sáenz Imbacuán (https://www.linkedin.com/in/rsaenzi/)
// Copyright © 2019. All rights reserved.
//
import UIKit
extension UIView {
func getNib() -> UINib {
return UINib(nibName: className(some: self), bundle: nil)
}
func loadNib() {
Bundle.main.loadNibNamed(className(some: self), owner: self, options: nil)
}
}
public func className(some: Any) -> String {
return (some is Any.Type) ? "\(some)" : "\(type(of: some))"
}
@rsaenzi
Copy link
Author

rsaenzi commented Mar 12, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment