質問です。
NSLayoutAnchorを試したいと思い
Swift
1 override func viewDidLoad() { 2 super.viewDidLoad() 3 // Do any additional setup after loading the view, typically from a nib 4 5 6 Test = UIView(frame: CGRect(x:0, y: 0, width: 100, height: 100)) 7 Test.backgroundColor = UIColor.green 8 Test.translatesAutoresizingMaskIntoConstraints = false 9 Test.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 30.0) .isActive = true 10 Test.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true 11 self.view.addSubview(Test) 12 13 14 } 15
以下のように簡単にコードを書いてみたのですが
シュミレートを起動した瞬間クラッシュします。
コードは間違ってないはずですが
どこが原因なのでしょうか??
アドバイスお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。