Code Monkey home page Code Monkey logo

visuality's Introduction

Visuality

At a Glance

Visuality helps you to create view or view controller instance with NIB by one line of code. This is the main purpose of this library. Actually, there's a lot more features!

How To Get Started

  • Copy content of Source folder to your project.

or

  • Use Swift package manager.

Requirements

  • iOS 9 and later
  • Xcode 9 and later
  • Swift 4

Usage

Views

To create new UIView instance, you have to use .from() static method:

MyView.from(nib: <nib query>, inBundle: <bundle query>)

Nib query can be one of the following values:

  • byNibName("MyView") - loads NIB with custom name
  • byClassName - loads NIB with name of view class
  • byClassNameWithSuffix(<suffix>) - loads NIB with name of view class and suffix
  • none - loads view without NIB

List of available suffixes for NIB name:

  • _iPhone
  • _iPad
  • custom("suffix")

Bundle query defines the bundle containing required NIB. Possible values are:

  • main - main bundle
  • byInstance(bundle) - requires instance of Bundle type
  • byIdentifier("com.example.App") - requires bundle identifier

So, if you need to initialize a view of MyView type with same-named NIB file located in main bundle, you can simply write:

let view = MyView.from(nib: .byClassName, inBundle: .main)

View Controllers

Initialization of view controller instances is very similar to view's initialization, but there's one more parameter:

let viewController = MyViewController.from(nib: .byClassName, inBundle: .main, loadView: true)

The last parameter loadView is a boolean value defining whether view should be loaded immediately after view controller's instantiation. In most cases you don't need to load view immediately, but, sometimes, this is a quite helpful option.

By default, loadView is false, so, if you don't need to load view controller's view immediately, you can avoid mentioning this parameter:

let viewController = MyViewController.from(nib: .byClassName, inBundle: .main)

In this case view will be loaded right before displaying on the screen.

License

Visuality is available under the MIT license. See the LICENSE file for more info.

visuality's People

Contributors

simplisticated avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.