Skip to content

Instantly share code, notes, and snippets.

@PiersonBro
Created October 23, 2014 17:00
Show Gist options
  • Save PiersonBro/e11ebe4e2e15d2bb6425 to your computer and use it in GitHub Desktop.
Save PiersonBro/e11ebe4e2e15d2bb6425 to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// Tester
//
import UIKit
import Cartography
class ViewController: UIViewController {
lazy var crashingView: UIView = {
UIView(frame: CGRect())
}()
override func viewDidLoad() {
super.viewDidLoad()
crashingView.backgroundColor = UIColor.purpleColor()
view.addSubview(crashingView)
// Crashes:
layout(crashingView) { (crashingView) in
crashingView.width == crashingView.superview!.width ~ 750
return
}
// Crashes as well:
// let constraint = NSLayoutConstraint(item: crashingView, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0)
// NSLayoutConstraint.activateConstraints([constraint])
// constraint.priority = 750
// Doesn't Crash
// let constraint = NSLayoutConstraint(item: crashingView, attribute: .Width, relatedBy: .Equal, toItem: view, attribute: .Width, multiplier: 1, constant: 0)
// constraint.priority = 750
// NSLayoutConstraint.activateConstraints([constraint])
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment