Add multiplier to NSLayoutAnchor constraints in Swift
问题 Anchor constraints simplify adding constraints but the multiplier property available in storyboard does not seem to be available for all types of constraints. For example, as per the answer here, you can center a label in a view with: view.addSubview(loadingLabel) loadingLabel.translatesAutoresizingMaskIntoConstraints = false loadingLabel.centerXAnchor.constraint(equalTo: view.centerXAnchor).isActive = true loadingLabel.centerYAnchor.constraint(equalTo: view.centerYAnchor).isActive = true