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
- the root view and
File's Ownermust be specified as your class, which inherits fromXibView - all outlets must be connected with
File's Ownerobject insidexib - root view in
xibmust have minimum 1 subview
As result you will get a view with hierarchy:
- MyView - file's owner
- MyView - root view
- subview
- subview
- subview
- MyView - root view
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 *