Last active
May 31, 2020 06:14
-
-
Save lengocgiang/ce1a6ee77161e2016217 to your computer and use it in GitHub Desktop.
UITextView height with AutoLayout( SnapKit)
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
// 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) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍