动态计算web高度,代理方法里
-(void)webViewDidFinishLoad:(UIWebView *)webView
{
CGFloat webViewHeight=[webView.scrollView contentSize].height;
CGRect newFrame = webView.frame;
newFrame.size.height = webViewHeight;
webView.frame = newFrame;
}
内容所占长度,CGSizeMake(Label宽度, 最大高度),lineBreakMode是文字换行模式
CGSize titleSize = [note sizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(209, 1000) lineBreakMode:UILineBreakModeWordWrap];
动态计算Label高度
NSString *str ;
CGRect rect = self.rejectInfo.frame;
NSDictionary *arrts = @{NSFontAttributeName : [UIFont systemFontOfSize:15.0]};
rect.size.height = [str boundingRectWithSize:CGSizeMake(WIDTH-30, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:arrts context:nil].size.height;
self.rejectInfo.frame = rect;
//顺畅显示中文加英文,设置换行模式
self.rejectInfo.lineBreakMode = NSLineBreakByCharWrapping;
self.rejectInfo.text = str;
网友评论