Skip to content

Commit

Permalink
Merge pull request #3 from Veo1oeV/Veo1oeV-patch-1
Browse files Browse the repository at this point in the history
Use addConstraints(_:) for better style
  • Loading branch information
yuhuili authored Oct 1, 2018
2 parents fb25544 + 604f093 commit 7d51ef3
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions Dino/Dino/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ class ViewController: NSViewController {
let c4 = NSLayoutConstraint(item: dinoSKView, attribute: .top, relatedBy: .equal, toItem: dinoView, attribute: .top, multiplier: 1.0, constant: 0)
let c5 = NSLayoutConstraint(item: dinoSKView, attribute: .bottom, relatedBy: .equal, toItem: dinoView, attribute: .bottom, multiplier: 1.0, constant: 0)

dinoView.addConstraint(c1)
dinoView.addConstraint(c2)
dinoView.addConstraint(c3)
dinoView.addConstraint(c4)
dinoView.addConstraint(c5)
dinoView.addConstraints([c1, c2, c3, c4, c5])

dinoView.wantsLayer = true
dinoView.layer?.backgroundColor = Constants.backgroundColor.cgColor
Expand All @@ -68,10 +64,7 @@ class ViewController: NSViewController {
let c3 = NSLayoutConstraint(item: dinoView, attribute: .top, relatedBy: .equal, toItem: touchBarView, attribute: .top, multiplier: 1.0, constant: 0)
let c4 = NSLayoutConstraint(item: dinoView, attribute: .bottom, relatedBy: .equal, toItem: touchBarView, attribute: .bottom, multiplier: 1.0, constant: 0)

touchBarView.addConstraint(c1)
touchBarView.addConstraint(c2)
touchBarView.addConstraint(c3)
touchBarView.addConstraint(c4)
touchBarView.addConstraints([c1, c2, c3, c4])

} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1, execute: {
Expand All @@ -90,10 +83,7 @@ class ViewController: NSViewController {
let c3 = NSLayoutConstraint(item: mainTapReceiverButton, attribute: .top, relatedBy: .equal, toItem: dinoView, attribute: .top, multiplier: 1.0, constant: 0)
let c4 = NSLayoutConstraint(item: mainTapReceiverButton, attribute: .bottom, relatedBy: .equal, toItem: dinoView, attribute: .bottom, multiplier: 1.0, constant: 0)

dinoView.addConstraint(c1)
dinoView.addConstraint(c2)
dinoView.addConstraint(c3)
dinoView.addConstraint(c4)
dinoView.addConstraints([c1, c2, c3, c4])
}

override var representedObject: Any? {
Expand Down

0 comments on commit 7d51ef3

Please sign in to comment.