NSMutableAttributedString 自定义文字内容的样式 间距,对其 方向 间隔之类

UIFont *contentLabelfont = [UIFont systemFontOfSize:KFONT_T9];
    CGSize contentLabelsize = CGSizeMake(WIDTH_OF_SCREEN - 12 - 12,2000);
    
    //    CGRect mycontentLabelRect = [model.info.content boundingRectWithSize:contentLabelsize options:(NSStringDrawingUsesLin eFragmentOrigin)  attributes:[NSDictionary dictionaryWithObject:contentLabelfont forKey:NSFontAttributeName] context:nil];
    
    NSMutableAttributedString *attriString = [[NSMutableAttributedString alloc] initWithString:model.info.content attributes:[NSDictionary dictionaryWithObject:contentLabelfont forKey:NSFontAttributeName]];
    NSMutableParagraphStyle * paragraph = [[NSMutableParagraphStyle alloc]init];
    [paragraph setLineSpacing:6];//设置行间距
    [paragraph setAlignment:NSTextAlignmentLeft];//设置对齐方式
    [paragraph setBaseWritingDirection:NSWritingDirectionLeftToRight];//设置书写方向
    [paragraph setParagraphSpacingBefore:10];//设置段后间距
    
    [attriString addAttribute:NSParagraphStyleAttributeName value:paragraph range:NSMakeRange(0, attriString.length)];
    
    //字间距
    long number = 1;
    CFNumberRef num = CFNumberCreate(kCFAllocatorDefault,kCFNumberSInt8Type,&number);
    [attriString addAttribute:(id)kCTKernAttributeName value:(__bridge id)num range:NSMakeRange(0,[attriString length])];
    CFRelease(num);
    
    CGRect mycontentLabelRect = [attriString boundingRectWithSize:contentLabelsize options:(NSStringDrawingUsesLineFragmentOrigin) context:nil];


这东西不能在 

tableView heightForRowAtIndexPath 
里面设置  计算高度  否则 8.1版本 会出现  加载到底 还有  

indexPath.row  = 0 的内容

你可能感兴趣的:(NSMutableAttributedString 自定义文字内容的样式 间距,对其 方向 间隔之类)