LoadableNib
helps you load views from xib file in a type-safe way. You'll be able to reuse UIView's subclass with simple code, no matter the class is the view's Custom Class
or File's Owner
.
Declare Your view to comform Loadable
protocol:
If you use the class that named SubclassName
as File's Owner
:
instantiateFromNibOwner(SubclassName.self)
Or you just set the custom name for the view with SubclassName
:
let instance:SubclassName = UIView().instantiateFromNib(SubclassName.self)
Supports from Swift 4.
Add the following line to your Podfile
:
pod 'LoadableNib', '~> 1.0.1'
Run pod install
.
Add the following line to your Cartfile
:
github "Ckitakishi/LoadableNib" ~> 1.0.1
- Run
carthage update
. - Find the
LoadableNib.framework
file at/Carthage/Build/*/
, then add it to Linked Frameworks and Libraries in your project.
MIT license.