Tiny utility to load UIView/NSView from nibs
Swift Ruby Objective-C
Latest commit 254212b Nov 6, 2016 @giginet committed on GitHub Merge pull request #6 from giginet/bump-up-to-2
Bump up to 2

README.md

NibLoaderKit

Build Status codecov Language Carthage compatible CocoaPods Compatible Platform License

This is a tiny utility to load UIView/NSView from nibs.

Usage

1. Declare CustomView class

class CustomView: UIView { }

2. Place CustomView.xib

  • xib must contains just one top level view.

3. Set custom class

  • Set custom class of the top level view to CustomView.

4. Load from the code

let customView: CustomView = try! CustomView.view(withOwner: self)

CustomView.xib will be loaded and generate the view.

Nib names are guessed automatically by class name. they would be demodulized.

You can also pass the nibName and bundle.

let customView: UIView = try! UIView.view(
    from: "MyCustomView", 
    owner: self, 
    bundle: Bundle(forClass: self.dynamicType)
)

Installation

Carthage

github "giginet/NibLoaderKit"

CocoaPods

use_frameworks!

pod 'NibLoaderKit'

Requirements

  • >= iOS 8
  • >= macOS 10.10
  • >= tvOS 9
  • Swift 3.0
  • Xcode 8.x

LICENSE

MIT License