Skip to content

Instantly share code, notes, and snippets.

@lengocgiang
Last active May 31, 2020 06:14
Show Gist options
  • Save lengocgiang/ce1a6ee77161e2016217 to your computer and use it in GitHub Desktop.
Save lengocgiang/ce1a6ee77161e2016217 to your computer and use it in GitHub Desktop.
UITextView height with AutoLayout( SnapKit)
// I'm using snapkit
// You can add to viewDidLoad
let address = UITextView(frame: CGRectZero)
address.text = restaurant.address
let sizeThatFits = address.sizeThatFits(CGSize(width: view.frame.width, height: CGFloat(MAXFLOAT)))
mainView.addSubview(address)
address.snp_makeConstraints { (make) -> Void in
let superview = mainView
make.top.equalTo(superview.snp_top)
make.left.equalTo(superview.snp_left)
make.right.equalTo(superview.snp_right)
make.height.equalTo(sizeThatFits)
}
@mazurio
Copy link

mazurio commented Oct 19, 2017

👍

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