Skip to content

Instantly share code, notes, and snippets.

@pnicholls
Created August 10, 2014 02:30
Show Gist options
  • Save pnicholls/7aa22dfce5a8a40f69b4 to your computer and use it in GitHub Desktop.
Save pnicholls/7aa22dfce5a8a40f69b4 to your computer and use it in GitHub Desktop.
import UIKit
class AuthenticationViewController: UIViewController {
// MARK: - Properties
var welcomeLabel: UILabel = {
let label = UILabel()
label.text = "Welcome to Paparazzi"
label.setTranslatesAutoresizingMaskIntoConstraints(false)
label.font = UIFont(name: "HelveticaNeue-Thin", size: 30)
label.textAlignment = .Center
return label
}()
var descriptionLabel: UILabel {
let label = UILabel()
label.text = "We'll text your phone number a confirmation code to get going."
label.setTranslatesAutoresizingMaskIntoConstraints(false)
label.font = UIFont(name: "HelveticaNeue-Thin", size: 14)
label.textColor = UIColor(red: 0.400, green: 0.400, blue: 0.400, alpha: 1)
label.numberOfLines = 0
label.textAlignment = .Center
return label
}
override func prefersStatusBarHidden() -> Bool {
return true
}
override func viewDidLoad() {
super.viewDidLoad()
navigationController.setNavigationBarHidden(true, animated: false)
view.backgroundColor = UIColor.whiteColor()
view.addSubview(welcomeLabel)
view.addSubview(descriptionLabel)
setupConstraints()
}
func setupConstraints() {
let views = [
"welcomeLabel": welcomeLabel,
"descriptionLabel": descriptionLabel
]
let metrics = [
"topPadding": 30,
"margin": 12
]
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("|-(margin)-[welcomeLabel]-(margin)-|", options: nil, metrics: metrics, views: views))
view.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|-(topPadding)-[welcomeLabel]", options: nil, metrics: metrics, views: views))
view.addConstraint(NSLayoutConstraint(item: descriptionLabel, attribute: .CenterY, relatedBy: .Equal, toItem: welcomeLabel, attribute: .CenterY, multiplier: 1, constant: 0))
}
}
@pnicholls
Copy link
Author

2014-08-10 12:19:35.774 TestApp[2657:60b] *** -[UILabel superview]: message sent to deallocated instance 0x135d14820

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