How to rewrite visual format
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("|-[label]-|", options: .AlignAllBaseline, metrics: nil, views: ["label": label]))
addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-[label]-|", options: .AlignAllCenterX, metrics: nil, views: ["label": label]))
label.topAnchor.constraintEqualToAnchor(layoutMarginsGuide.topAnchor).active = true
label.leftAnchor.constraintEqualToAnchor(layoutMarginsGuide.leftAnchor).active = true
label.bottomAnchor.constraintEqualToAnchor(layoutMarginsGuide.bottomAnchor).active = true
label.rightAnchor.constraintEqualToAnchor(layoutMarginsGuide.rightAnchor).active = true
It seems to me that layoutMarginsGuide is not ready in the init method of a UIView. I'm also getting similar issues, where setting up the constraints in updateConstraints just works. Still investigating why.
UPDATE: What I was trying to do was set the layoutMargins before the view had been added to a superview (in the init). That didn't work. What did work was setting the constraints in the init, relative to layoutMarginsGuide, but actually setting the layoutMargins in viewDidMoveToSuperView.