MaciejGad / NibBased

🧱 A micro-framework that helps to handle xib/nib based layout.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NibBased

A micro-framework that helps to handle xib/nib based layout. If you prefer to avoid usage of storyboards in your project, this few classes will help you organized your view related part of the code.

Basic assumption

The basic assumption for this framework is to have nib (xib) file with the same name as class. So if you have YouViewController class the corresponding xib file will be named YouViewController.xib. This rule is also valid for UIView, UITableViewCell and UICollectionViewCell subclasses.

Usage

There are a few ways to use this library. The most popular is to use NibBaseViewController as a basic class for other view controllers in your application. Firstly you have to create a view controller subclass using File -> New -> File menu in Xcode. Select Cocoa Touch Class and then set Subclass of to NibBaseViewController and don't forget to select Also create a XIB file. In a newly created file, you have to add import NibBased so your file should look similar to:

import UIKit
import NibBased

class YourViewController: NibBaseViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
    }
}

and then in the place when you want to load your view controller write just:

let viewController = YourViewController()

and it will load your layout from YourViewController.xib file.

Installation

Use the CocoaPods.

Add to your Podfile

pod 'NibBased'

and then call

pod install

and import

import NibBased

About

🧱 A micro-framework that helps to handle xib/nib based layout.

License:MIT License


Languages

Language:Swift 92.2%Language:Ruby 4.9%Language:Objective-C 2.9%