Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/giginet/nibloaderkit
Tiny utility to load UIView/NSView from nibs
https://github.com/giginet/nibloaderkit
Last synced: 3 months ago
JSON representation
Tiny utility to load UIView/NSView from nibs
- Host: GitHub
- URL: https://github.com/giginet/nibloaderkit
- Owner: giginet
- License: mit
- Created: 2016-07-02T16:58:31.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-04T06:52:43.000Z (over 6 years ago)
- Last Synced: 2024-10-12T16:18:56.787Z (3 months ago)
- Language: Swift
- Homepage:
- Size: 105 KB
- Stars: 15
- Watchers: 4
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# NibLoaderKit
[![Build Status](https://travis-ci.org/giginet/NibLoaderKit.svg?branch=master)](https://travis-ci.org/giginet/NibLoaderKit)
[![codecov](https://codecov.io/gh/giginet/NibLoaderKit/branch/master/graph/badge.svg)](https://codecov.io/gh/giginet/NibLoaderKit)
[![Language](https://img.shields.io/badge/language-Swift%204.1-orange.svg)](https://swift.org)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/NibLoaderKit.svg)](http://cocoadocs.org/docsets/NibLoaderKit)
[![Platform](https://img.shields.io/cocoapods/p/NibLoaderKit.svg?style=flat)](http://cocoadocs.org/docsets/NibLoaderKit)
[![License](https://cocoapod-badges.herokuapp.com/l/NibLoaderKit/badge.svg)](https://github.com/giginet/NibLoaderKit/blob/master/LICENSE.md)This is a tiny utility to load UIView/NSView from nibs.
# Usage
## 1. Declare CustomView class
```swift
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`.
![](https://raw.githubusercontent.com/giginet/NibLoaderKit/master/Documentation/Images/custom_view.png)
## 4. Load from the code
```swift
let customView: CustomView = try! CustomView.view(with: 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.
```swift
let customView: UIView = try! UIView.view(
from: "MyCustomView",
owner: self,
bundle: Bundle(forClass: self.dynamicType)
)
```# Installation
## Carthage
```
github "giginet/NibLoaderKit"
```## CocoaPods
```ruby
use_frameworks!pod 'NibLoaderKit'
```# Requirements
- >= iOS 8
- >= macOS 10.10
- >= tvOS 9
- Swift 4.1
- Xcode 9.4## LICENSE
MIT License