Skip to content

Instantly share code, notes, and snippets.

@johndpope-karhoo
Created September 20, 2016 19:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johndpope-karhoo/68582406fe4e06f8302725a3105e9a91 to your computer and use it in GitHub Desktop.
Save johndpope-karhoo/68582406fe4e06f8302725a3105e9a91 to your computer and use it in GitHub Desktop.
import Foundation
import SnapKit
class SnapkitExampleContainer:SnapKitHelperView{
// TODO - remove xcode constraints and
private lazy var supplierImageContainer: UIView = self.viewByTag(500)
private lazy var statusLabel: UILabel = self.labelByTag(501)
private lazy var detailsViewSnapkitContainer: UIView = self.viewByTag(502)
private lazy var creditCardView: UIView = self.viewByTag(503)
private lazy var acceptedLabel: UILabel = self.labelByTag(505)
private lazy var bookingRecievedContainer: UIView = self.viewByTag(506)
private lazy var expandImage: UIImageView = self.imageViewByTag(507)
var runOnce = false
override func layoutSubviews() {
super.layoutSubviews()
// REMOVE XCODE CONSTRAINTS ONCE
if (!runOnce){
runOnce = true
self.removeConstraints(self.constraints)
self.snp_makeConstraints { (make) -> Void in
make.height.equalTo(255).priorityMedium()
}
supplierImageContainer.snp_makeConstraints { (make) -> Void in
let yOffset = supplierImageContainer.frame.height/2
make.top.equalTo(self).offset(-yOffset)
make.centerX.equalTo(self)
}
statusLabel.snp_makeConstraints { (make) -> Void in
make.top.equalTo(self).offset(50)
make.centerX.equalTo(self)
}
detailsViewSnapkitContainer.snp_makeConstraints { (make) -> Void in
make.bottom.equalTo(self).offset(-60)
make.left.equalTo(self)
}
creditCardView.snp_makeConstraints { (make) -> Void in
make.bottom.equalTo(self)
make.centerX.equalTo(self)
}
acceptedLabel.snp_makeConstraints { (make) -> Void in
make.centerX.equalTo(self)
make.centerY.equalTo(self)
}
bookingRecievedContainer.snp_makeConstraints { (make) -> Void in
let yCreditCardOffset = creditCardView.frame.height
make.bottom.equalTo(self).offset(-yCreditCardOffset)
make.width.equalTo(self)
make.left.equalTo(self)
}
expandImage.snp_makeConstraints { (make) -> Void in
make.top.equalTo(self).offset(10)
make.right.equalTo(self).offset(-12)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment