UITextView自适应高度

- (float) heightForTextView: (UITextView *)textView WithText: (NSString *) strText{

    float fPadding = 10.0;

    CGSize constraint = CGSizeMake(textView.contentSize.width - fPadding, CGFLOAT_MAX);

    

    CGSize size = [strText sizeWithFont: textView.fontconstrainedToSize:constraint lineBreakMode:NSLineBreakByWordWrapping];

    

    float fHeight = size.height + 5.0;

    

    return fHeight;

}

原文地址:https://www.cnblogs.com/cocoajin/p/3248167.html