首页 > 解决方案 > 如何使用石英 2D 在 iOS Objective-C 的 pdf 文本区域中添加行距?

问题描述

我使用核心图形 ( Image ) 创建了一个带有框的 PDF 页面。

我面临一个问题,即评论部分我无法明智地设置“文本”。知道我该怎么做吗?

“评论”部分的代码。

textToDraw=@"Comments:";
newfont=fontName2(7);
renderingRect = CGRectMake(20,146.5, 842, 300.0);
[textToDraw drawInRect:renderingRect withFont:newfont lineBreakMode:nil alignment:nil];



////////////////
CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,155);
CGContextAddLineToPoint(currentContext,295, 155);
CGContextStrokePath(currentContext);

CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,170);
CGContextAddLineToPoint(currentContext,295, 170);
CGContextStrokePath(currentContext);



CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,185);
CGContextAddLineToPoint(currentContext,295, 185);
CGContextStrokePath(currentContext);



CGContextSetLineWidth(currentContext, 1.0);
CGContextMoveToPoint(currentContext, 20,200);
CGContextAddLineToPoint(currentContext,295, 200);
CGContextStrokePath(currentContext);


@try{


    textToDraw=@"";
    NSString *commentText=@"helo how are you. i am tuna  string. i have so many friends. helllo i am working.here is my paragraph writing";

    renderingRect = CGRectMake(62, 146, 220, 400);
    newfont=fontName2(7);
    [commentText drawInRect:renderingRect withFont:newfont    lineBreakMode:NSLineBreakByWordWrapping alignment:NSTextAlignmentLeft];



       }

              @catch(NSException *e){

   }

标签: objective-cxcode9.2

解决方案


推荐阅读