Last active
March 12, 2020 04:25
-
-
Save rsaenzi/0c3da9a1f5084c6ac73cee0b501daf33 to your computer and use it in GitHub Desktop.
Util functions for UIViews
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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))" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CustomView.swift
https://gist.github.com/rsaenzi/1f5b02729ad42e6ca063e9db7d84408d