Created
April 19, 2017 16:32
-
-
Save samwarnick/341ffc3f2c33361a49c4f8eee4d6931e to your computer and use it in GitHub Desktop.
Example configureViews function of a view controller
This file contains 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
func configureViews() { | |
let authorLabel = UILabel() | |
authorLabel.defaultStlye() | |
authorLabel.text = "Created by Sam Warnick" | |
let websiteButton = UIButton(type: .system) | |
websiteButton.defaultStlye() | |
websiteButton.setTitle("samwarnick.com", for: .normal) | |
websiteButton.addTarget(self, action: #selector(STNCreditsViewController.didPressWebisteButton), for: .touchUpInside) | |
websiteButton.sizeToFit() | |
let twitterButton = UIButton(type: .system) | |
twitterButton.defaultStlye() | |
twitterButton.setTitle("@samwarnick", for: .normal) | |
twitterButton.addTarget(self, action: #selector(STNCreditsViewController.didPressTwitterButton), for: .touchUpInside) | |
twitterButton.sizeToFit() | |
let contactLabel = UILabel() | |
contactLabel.defaultStlye() | |
contactLabel.font = UIFont.systemFont(ofSize: 12, weight: UIFontWeightThin) | |
contactLabel.text = "Please get in touch on Twitter or my website with any feedback" | |
let myDetailsStackView = UIStackView(arrangedSubviews: [authorLabel, websiteButton, twitterButton, contactLabel]) | |
myDetailsStackView.axis = .vertical | |
myDetailsStackView.alignment = .center | |
myDetailsStackView.distribution = .equalSpacing | |
myDetailsStackView.spacing = 8 | |
myDetailsStackView.sizeToFit() | |
view.addSubview(myDetailsStackView) | |
myDetailsStackView.snp.makeConstraints { (make) -> Void in | |
make.centerY.equalTo(view) | |
make.left.equalTo(view).offset(40) | |
make.right.equalTo(view).offset(-40) | |
} | |
view.backgroundColor = UIColor.white | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment