I\'m trying to figure this out since last week without going any step further. Ok, so I need to apply some constraints programmatically
You are adding all defined constraints to self.view
which is wrong, as width and height constraint should be added to your newView
.
Also, as I understand you want to set constant width and height 100:100. In this case you should change your code to:
var constW = NSLayoutConstraint(item: newView,
attribute: .Width,
relatedBy: .Equal,
toItem: nil,
attribute: .NotAnAttribute,
multiplier: 1,
constant: 100)
newView.addConstraint(constW)
var constH = NSLayoutConstraint(item: newView,
attribute: .Height,
relatedBy: .Equal,
toItem: nil,
attribute: .NotAnAttribute,
multiplier: 1,
constant: 100)
newView.addConstraint(constH)