iOS 开发小技巧

根据返回的web 获取高度

//页面加载完成之后调用

- (void)webView:(WKWebView*)webView didFinishNavigation:(WKNavigation*)navigation {    

[webView evaluateJavaScript:@"document.body.offsetHeight;" completionHandler:^(id _Nullable any, NSError * _Nullable error) {

        CGSize maxSize =CGSizeMake(Width-30,MAXFLOAT);

        //计算attributedString的rect

        CGSize size = [_label_Title.attributedText boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin context:nil].size;

//获取总高度

       double height = [any floatValue]+ size.height+35;

    }];

}

你可能感兴趣的:(iOS 开发小技巧)