-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathNibView.swift
52 lines (40 loc) · 1.26 KB
/
NibView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// NibView.swift
// NibView
//
// Created by Domas on 10/02/2017.
// Copyright © 2016 Trafi. All rights reserved.
//
#if canImport(NibView)
import NibView
#endif
import UIKit
open class NibView: UIView, NibLoadable {
open class var nibName: String {
return String(describing: self)
}
open class var bundle: Bundle {
return Bundle(for: self)
}
open override func awakeAfter(using aDecoder: NSCoder) -> Any? {
return nibLoader.awakeAfter(using: aDecoder, super.awakeAfter(using: aDecoder))
}
// MARK: - Interface builder
#if TARGET_INTERFACE_BUILDER
public override init(frame: CGRect) {
super.init(frame: frame)
nibLoader.initWithFrame()
}
public required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
open override func prepareForInterfaceBuilder() {
super.prepareForInterfaceBuilder()
nibLoader.prepareForInterfaceBuilder()
}
open override func setValue(_ value: Any?, forKeyPath keyPath: String) {
super.setValue(value, forKeyPath: keyPath)
nibLoader.setValue(value, forKeyPath: keyPath)
}
#endif
}