Skip to content

Swift UIView subclass that loads itself from a companion NIB for widget development.

License

Notifications You must be signed in to change notification settings

edelabar/NibLoadedView

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NibLoadedView

Swift UIView subclass that loads itself from a companion NIB for widget development.

This is a Swift port of the technique covered in An Update on Nested Nib Loading by Yang Meyer (@yangmeyer).

If your class extends this class, you can set a UIView in a Storyboard or Nib file with your custom class and it will load a similarly named .xib file. For example, if you build MyView.xib and MyView.swift, set the custom class in Interface Builder to MyView.swift and it will load the NIB at runtime.

As a bonus, with Xcode 6, if you make your subclass @IBDesignable the view will render in Interface Builder!

For a working example, see edelabar/AutoLayoutTester. There's a more in-depth article coming soon.

Thanks

This project uses nameOfClass.swift from indieSoftware/INSwift, thanks to Sven Korset for sharing, and of course, thanks to Yang Meyer for writing his original article.

About

Swift UIView subclass that loads itself from a companion NIB for widget development.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages