UITextView如何计算高度

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)
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *