Skip to content

Instantly share code, notes, and snippets.

@Aymenworks
Created January 18, 2019 02:58
Show Gist options
  • Save Aymenworks/5d7f9854938cd38783b58e3a27354c74 to your computer and use it in GitHub Desktop.
Save Aymenworks/5d7f9854938cd38783b58e3a27354c74 to your computer and use it in GitHub Desktop.
// ...
func setup() {
// ...
layout: do {
addSubview(backgroundButton)
addSubview(foregroundButton)
backgroundButton.translatesAutoresizingMaskIntoConstraints = false
foregroundButton.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
backgroundButton.leadingAnchor.constraint(equalTo: leadingAnchor),
backgroundButton.topAnchor.constraint(equalTo: topAnchor),
backgroundButton.trailingAnchor.constraint(equalTo: trailingAnchor),
backgroundButton.bottomAnchor.constraint(equalTo: bottomAnchor),
foregroundButton.leftAnchor.constraint(equalTo: backgroundButton.leftAnchor),
foregroundButton.topAnchor.constraint(equalTo: backgroundButton.topAnchor),
foregroundButton.rightAnchor.constraint(equalTo: backgroundButton.rightAnchor),
foregroundButton.bottomAnchor.constraint(equalTo: backgroundButton.bottomAnchor),
])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment