Skip to content

Commit 09e3c3b

Browse files
committed
refactor(BaseNibView): improve programmatically added constraints using new syntax
1 parent 7cd0993 commit 09e3c3b

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

SoundWave/Classes/BaseNibView.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ public class BaseNibView: UIView {
8282

8383
self.contentView.translatesAutoresizingMaskIntoConstraints = false
8484
self.addSubview(self.contentView)
85-
86-
let leadingConstraint = NSLayoutConstraint(item: self.contentView, attribute: .leading, relatedBy: .equal, toItem: self, attribute: .leading, multiplier: 1.0, constant: 0.0)
87-
let topConstraint = NSLayoutConstraint(item: self.contentView, attribute: .top, relatedBy: .equal, toItem: self, attribute: .top, multiplier: 1.0, constant: 0.0)
88-
let trailingConstraint = NSLayoutConstraint(item: self.contentView, attribute: .trailing, relatedBy: .equal, toItem: self, attribute: .trailing, multiplier: 1.0, constant: 0.0)
89-
let bottomConstraint = NSLayoutConstraint(item: self.contentView, attribute: .bottom, relatedBy: .equal, toItem: self, attribute: .bottom, multiplier: 1.0, constant: 0.0)
9085

91-
self.addConstraints([leadingConstraint, topConstraint, trailingConstraint, bottomConstraint])
86+
self.contentView.topAnchor.constraint(equalTo: self.topAnchor).isActive = true
87+
self.contentView.bottomAnchor.constraint(equalTo: self.bottomAnchor).isActive = true
88+
self.contentView.leftAnchor.constraint(equalTo: self.leftAnchor).isActive = true
89+
self.contentView.rightAnchor.constraint(equalTo: self.rightAnchor).isActive = true
9290
}
9391
}

0 commit comments

Comments
 (0)