IOS 字符串高度

测试代码

- (void)testStrFrame
{
   NSString  *ContentStr = @"ennghjkjhgfdfghjkjhgfwertyuiowertyuioertyuqwertyuiedrtyuiwertyuwertywertyyuiowertyuioertyuqwertyuiedrtyuiwertyuwertywerty";

    CGSize size = [ContentStr getSizeWithFont:[UIFont systemFontOfSize:15] constrainedToSize:CGSizeMake(320, MAXFLOAT)];
    
    UILabel *_labelTest = [[UILabel alloc]init];
    _labelTest.numberOfLines = 0;
    _labelTest.font = [UIFont systemFontOfSize:15];
    _labelTest.frame = CGRectMake(0, 64, 320,size.height);
    _labelTest.text = ContentStr;
    
    [self.view addSubview:_labelTest];
    
}


你可能感兴趣的:(IOS 字符串高度)