File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ //
2+ // CustomView.swift
3+ // Pods
4+ //
5+ // Created by Nicolas LELOUP on 31/08/2017.
6+ //
7+ //
8+
9+ import Foundation
10+ import SnapKit
11+ import UIKit
12+
13+ protocol OwnViewProtocol {
14+ var viewName : String { get }
15+ }
16+
17+ class OwnView : UIView {
18+ var contentView : UIView !
19+
20+ override init ( frame: CGRect ) {
21+ super. init ( frame: frame)
22+ self . loadView ( )
23+ }
24+
25+ required init ( coder: NSCoder ) {
26+ super. init ( coder: coder) !
27+ self . loadView ( )
28+ }
29+
30+ func loadView( ) {
31+ if let conformingProtocolView = self as? OwnViewProtocol {
32+ self . contentView = Bundle . main. loadNibNamed (
33+ conformingProtocolView. viewName,
34+ owner: self ,
35+ options: nil
36+ ) ? . last as? UIView
37+ self . addSubview ( self . contentView)
38+ self . contentView. snp. makeConstraints ( { ( maker) in
39+ maker. edges. equalTo ( self )
40+ } )
41+ }
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments