---
title: "计算字符串高度"
author: "修博龙泉"
date: "2013-04-10T11:39:00Z"
tags: []
categories: ["移动开发"]
slug: "untitled"
draft: false
lastmod: "2013-04-10T11:39:00Z"
id: 1844966
url: "https://longquan.iteye.com/blog/1844966"
---

```java

- (float)countHeightOfString:(NSString *)string WithWidth:(float)width Font:(UIFont *)font {
	if ([nsnull null] == (id)string) {
		string = @"暂时没有数据";
	}
	CGSize constraintSize = CGSizeMake(width,500);//MAXFLOAT
	CGSize labelSize = [string sizewithfont:font constrainedtosize:constraintsize linebreakmode:uilinebreakmodewordwrap];
    
	return labelSize.height+10;
}

```