Skip to content

Instantly share code, notes, and snippets.

@martinnormark
Last active September 23, 2020 08:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinnormark/bc576e7938a3449360f0 to your computer and use it in GitHub Desktop.
Save martinnormark/bc576e7938a3449360f0 to your computer and use it in GitHub Desktop.
Example of updateConstraints using PureLayout
private var didUpdateConstraints: Bool = false
override func updateConstraints() {
if (!didUpdateConstraints) {
self.buildStatusIndicatorView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsZero, excludingEdge: ALEdge.Trailing)
self.buildStatusIndicatorView.autoSetDimension(ALDimension.Width, toSize: 10)
self.buildNumberLabel.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsets(top: 5, left: 15, bottom: 5, right: 5), excludingEdge: ALEdge.Bottom)
self.buildNumberLabel.autoSetDimension(ALDimension.Height, toSize: 23)
self.branchLabel.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Top, ofView: self.contentView, withOffset: 10)
self.branchLabel.autoPinEdge(ALEdge.Trailing, toEdge: ALEdge.Trailing, ofView: self.contentView, withOffset: -10)
self.commitMessageLabel.autoPinEdge(ALEdge.Top, toEdge: ALEdge.Bottom, ofView: self.buildNumberLabel, withOffset: 10)
self.commitMessageLabel.autoPinEdgeToSuperviewEdge(ALEdge.Leading, withInset: 15)
self.commitMessageLabel.autoPinEdgeToSuperviewEdge(ALEdge.Bottom, withInset: 5)
self.commitMessageLabel.autoConstrainAttribute(ALAttribute.Width, toAttribute: ALAttribute.Width, ofView: self.contentView, withOffset: -20)
didUpdateConstraints = true
}
super.updateConstraints()
}
@acalism
Copy link

acalism commented Sep 23, 2020

I used to do the same thing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment