-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathStackViewItem.swift
More file actions
42 lines (34 loc) · 940 Bytes
/
StackViewItem.swift
File metadata and controls
42 lines (34 loc) · 940 Bytes
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
//
// ViewControllerConvertible.swift
// Seed
//
// Created by Indragie Karunaratne on 1/29/16.
// Copyright © 2016 Seed Platform, Inc. All rights reserved.
//
import UIKit
public protocol StackViewItem: AnyObject {
func toViewController() -> UIViewController
}
extension UIViewController: StackViewItem {
public func toViewController() -> UIViewController {
return self
}
}
extension UIView: StackViewItem {
public func toViewController() -> UIViewController {
return WrapperViewController(view: self)
}
}
private class WrapperViewController: UIViewController {
fileprivate let _view: UIView
init(view: UIView) {
_view = view
super.init(nibName: nil, bundle: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
fileprivate override func loadView() {
view = _view
}
}