How to test drive view in iOS

Issue #303

Instead of setting up custom framework and Playground, we can just display that specific view as root view controller

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
window.rootViewController = makeTestPlayground()

func makeTestPlayground() -> UIViewController {
let content = UserCell()
content.nameLabel.text = "Thor"
content.streetLabel.text = "Asgard"
content.weaponLabel.text = "Hammer"

let viewController = UIViewController()
viewController.view.backgroundColor = .white
viewController.view.addSubview(content)

NSLayoutConstraint.on([
content.centerXAnchor.constraint(equalTo: viewController.view.centerXAnchor),
content.centerYAnchor.constraint(equalTo: viewController.view.centerYAnchor),
content.widthAnchor.constraint(equalTo: viewController.view.widthAnchor, multiplier0.9),
content.heightAnchor.constraint(equalToConstant: 200)
]
return viewController
}

Comments