-
-
Save susieyy/74de0a4e652952f55fa4e8fe7cef5034 to your computer and use it in GitHub Desktop.
#swtws
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
protocol InstantiatableFromNib { | |
static var nibName: String { get } | |
static func instantiateFromNib() -> Self | |
} | |
extension InstantiatableFromNib where Self: UIView { | |
static var nibName: String { | |
get { return String(Self.self) } | |
} | |
static func instantiateFromNib() -> Self { | |
let nib = UINib(nibName: nibName, bundle: nil) | |
return nib.instantiateWithOwner(nil, options: nil).first as! Self | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment