All Projects → trafi → Nibview

trafi / Nibview

Licence: mit
Tiny Swift framework to reference nibs from anywhere - code, other nibs or storyboards ✨

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Nibview

STTextView
📝 STTextView is a light-weight library that adds a placeholder to the UITextView.
Stars: ✭ 36 (-33.33%)
Mutual labels:  carthage, interface-builder
Switch
💊 An iOS switch control implemented in Swift with full Interface Builder support
Stars: ✭ 132 (+144.44%)
Mutual labels:  carthage, interface-builder
Tweetextfield
Lightweight set of text fields with nice animation and functionality. 🚀 Inspired by https://uimovement.com/ui/2524/input-field-help/
Stars: ✭ 421 (+679.63%)
Mutual labels:  carthage, interface-builder
Simplecheckbox
A simple Checkbox
Stars: ✭ 253 (+368.52%)
Mutual labels:  carthage, interface-builder
Uitextfield Navigation
🏄‍♂️ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews
Stars: ✭ 436 (+707.41%)
Mutual labels:  carthage, interface-builder
Gaugekit
Kit for building custom gauges + easy reproducible Apple's style ring gauges.
Stars: ✭ 997 (+1746.3%)
Mutual labels:  carthage
Magiql
🌐 💫 Simple and powerful GraphQL Client, love child of react-query ❤️ relay
Stars: ✭ 45 (-16.67%)
Mutual labels:  magic
Swiftysound
SwiftySound is a simple library that lets you play sounds with a single line of code.
Stars: ✭ 995 (+1742.59%)
Mutual labels:  carthage
Centeredcollectionview
A lightweight UICollectionViewLayout that 'pages' and centers its cells 🎡 written in Swift
Stars: ✭ 965 (+1687.04%)
Mutual labels:  carthage
Stravakit
Strava API Client built with Swift
Stars: ✭ 50 (-7.41%)
Mutual labels:  carthage
React Native Ezplayer
EZPlayer component for react-native apps
Stars: ✭ 47 (-12.96%)
Mutual labels:  carthage
Mystique
A wrapper for CoreAnimation.
Stars: ✭ 43 (-20.37%)
Mutual labels:  carthage
Fontblaster
Programmatically load custom fonts into your iOS and tvOS app.
Stars: ✭ 1,000 (+1751.85%)
Mutual labels:  carthage
10 Simple Hacks To Speed Up Your Data Analysis In Python
Some useful Tips and Tricks to speed up the data analysis process in Python.
Stars: ✭ 45 (-16.67%)
Mutual labels:  magic
Grview
UIView and other UIKit elements with a gradient and other attributes for IOS
Stars: ✭ 39 (-27.78%)
Mutual labels:  carthage
Swiftymessenger
Swift toolkit for passing messages between iOS apps and extensions.
Stars: ✭ 48 (-11.11%)
Mutual labels:  carthage
Sica
🦌 Simple Interface Core Animation. Run type-safe animation sequencially or parallelly
Stars: ✭ 980 (+1714.81%)
Mutual labels:  carthage
Imagecoordinatespace
UICoordinateSpace for UIImageView image
Stars: ✭ 42 (-22.22%)
Mutual labels:  carthage
Mobx React Form
Reactive MobX Form State Management
Stars: ✭ 1,031 (+1809.26%)
Mutual labels:  magic
Wstagsfield
An iOS text field that represents tags, hashtags, tokens in general.
Stars: ✭ 1,013 (+1775.93%)
Mutual labels:  carthage

Swift Package Manager compatible Carthage compatible

NibView

@IBDesignable class MyView: NibView {} // That's it! ✨

Preview

Tiny Swift framework to reference nibs from anywhere - code, other nibs or storyboards ✨

Capabilities
True rendering inside interface builder with @IBDesignable and @IBInspectable
📏 Calculates correct intrinsic content size
♻️ Referencing from other nibs and storyboards - keeping them small
⌨️ Loading from code with a simple .fromNib()
⚙️ Integrates as little or as much

Play around with Example project 🕹️👈

Usage

Subclass NibView

Just subclass NibView and optionally add @IBDesignable attribute. That's it! ✨

@IBDesignable class MyView: NibView {}

Setup

⚠️ Usage If subclassing is not an option.

Implement NibLoadable

Implementing NibLoadable protocol and overriding a couple of functions will unleash the full power of referencing 💪

⌨️ - Code

To reference nibs only from code implement NibLoadable protocol:

class MyView: SomeBaseView, NibLoadable {
    // 'nibName' defaults to class name. "MyView" in this case.
    class var nibName: String { return "MyCustomView" }
}
let myView = MyView.fromNib()

💻 - IB

To reference nibs from interface builder (other nibs or storyboards) in addition to implementing NibLoadable override awakeAfter(using:) with a call to nibLoader - a helper struct from 'NibLoadable' protocol:

class MyView: SomeBaseView, NibLoadable {
    override func awakeAfter(using aDecoder: NSCoder) -> Any? {
        return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder))
    }
}

⚡️📱✨ - @IBDesignable

To get real rendering and intrinsic content size from the nib - @IBDesignable attribute and some overrides are needed:

@IBDesignable
class MyView: SomeBaseView, NibLoadable {
    
    open override func awakeAfter(using aDecoder: NSCoder) -> Any? {
        return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder))
    }
    
    #if TARGET_INTERFACE_BUILDER
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        nibLoader.initWithFrame()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override func prepareForInterfaceBuilder() {
        super.prepareForInterfaceBuilder()
        nibLoader.prepareForInterfaceBuilder()
    }

    override func setValue(_ value: Any?, forKeyPath keyPath: String) {
        super.setValue(value, forKeyPath: keyPath)
        nibLoader.setValue(value, forKeyPath: keyPath)
    }
    
    #endif
}

Installation

Carthage

Drag NibView.swift file into your Xcode project and add the following line to your Cartfile:

github "Trafi/NibView"

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/trafi/NibView.git", .upToNextMajor(from: "2.0.0"))
]

Manual

Drag the Sources folder and NibView.swift file into your Xcode project.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].