Skip to content

This library provides a way to create views from xib files

License

Notifications You must be signed in to change notification settings

NikSativa/XibKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XibKit

This library provides a way to create views from xib files. It's useful when you need to create a custom view with a complex hierarchy of subviews.

Important

  1. the root view and File's Owner must be specified as your class, which inherits from XibView
  2. all outlets must be connected with File's Owner object inside xib
  3. root view in xib must have minimum 1 subview

As result you will get a view with hierarchy:

  • MyView - file's owner
    • MyView - root view
      • subview
      • subview
      • subview

How to create from code:

let main: XibViewMain = .init()
view.addSubview(main)

You can use you custom views inside other xib/storyboard by setting class type to your custom view class and connect outlets to it. To handle correct size in xib just set intrinsic size to placeholder.

How to create from other xib:

final class MyViewController: UIViewController {
    @IBOutlet weak var main: XibViewMain!
}

PS: see XibViewMain.xib and XibViewMain.swift as example *