https://github.com/niksativa/xibkit
This library provides a way to create views from xib files
https://github.com/niksativa/xibkit
custom ios storyboard swift uiview view xib
Last synced: 17 days ago
JSON representation
This library provides a way to create views from xib files
- Host: GitHub
- URL: https://github.com/niksativa/xibkit
- Owner: NikSativa
- License: mit
- Created: 2023-04-03T08:45:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-12T12:08:33.000Z (over 1 year ago)
- Last Synced: 2024-04-14T06:46:22.606Z (over 1 year ago)
- Topics: custom, ios, storyboard, swift, uiview, view, xib
- Language: Swift
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XibKit
[](https://swiftpackageindex.com/NikSativa/XibKit)
[](https://swiftpackageindex.com/NikSativa/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:
```swift
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`:
```swift
final class MyViewController: UIViewController {
@IBOutlet weak var main: XibViewMain!
}
```
*
PS:
see [XibViewMain.xib](./Tests/views/XibViewMain.xib) and [XibViewMain.swift](./Tests/views/XibViewMain.swift) as example
*