Skip to content

Instantly share code, notes, and snippets.

@gekitz
Created July 23, 2014 21:10
Show Gist options
  • Save gekitz/76cfc1d206d9d8742e71 to your computer and use it in GitHub Desktop.
Save gekitz/76cfc1d206d9d8742e71 to your computer and use it in GitHub Desktop.
Why do I have to do this, shouldn't autolayout figure out the height on it's own?
class GKTextAlertContentView: UIView {
@IBOutlet var titleLabel: UILabel!
@IBOutlet var textLabel: UILabel!
@IBOutlet var textField: UITextField!
@IBOutlet var submitButton: UIButton!
override func intrinsicContentSize() -> CGSize {
let titleSize = titleLabel.intrinsicContentSize()
let textSize = textLabel.intrinsicContentSize()
let textFieldSize = textField.intrinsicContentSize()
let btnSize = submitButton.intrinsicContentSize()
let dist: CGFloat = 10.0
let height = dist + titleSize.height + dist + textSize.height + dist + textFieldSize.height + dist + btnSize.height + dist + dist
return CGSize(width: 280, height: height)
}
}
@gekitz
Copy link
Author

gekitz commented Jul 23, 2014

Why do I have to do this, shouldn't autolayout figure out the height on it's own?

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