Created
January 18, 2019 02:56
-
-
Save Aymenworks/9a9fd5b87c331ab39daa8ff999e3fd7c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchView: UIView { | |
// MARK: Properties | |
... | |
// MARK: Setup | |
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