Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c CTFramesetterCreateWithAttributedString don';不要创建最后一行_Objective C_Ios - Fatal编程技术网

Objective c CTFramesetterCreateWithAttributedString don';不要创建最后一行

Objective c CTFramesetterCreateWithAttributedString don';不要创建最后一行,objective-c,ios,Objective C,Ios,为什么这个代码只给我一行?但是如果我写@“line1\n\0”,那么我将有两行!为什么最后一个'\n'不创建新行 CTFramesetterRef ctfsr = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)[[NSAttributedString alloc] initWithString:@"line1\n"]); CGSize suggestedSize = CTFramesette

为什么这个代码只给我一行?但是如果我写@“line1\n\0”,那么我将有两行!为什么最后一个'\n'不创建新行

CTFramesetterRef ctfsr = CTFramesetterCreateWithAttributedString((__bridge CFAttributedStringRef)[[NSAttributedString alloc] initWithString:@"line1\n"]);
    CGSize suggestedSize = CTFramesetterSuggestFrameSizeWithConstraints(ctfsr, CFRangeMake(0, 0), NULL, CGSizeMake(width, CGFLOAT_MAX), NULL);
    CGRect tempRect = CGRectMake(0, 0, _textContentView.bounds.size.width, suggestedSize.height);
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:tempRect];
    CTFrameRef ctfr = CTFramesetterCreateFrame(ctfsr, CFRangeMake(0, 0), [path CGPath], NULL);
    NSArray* lines = (__bridge NSArray*)CTFrameGetLines(ctfr);
    NSLog(@"%@", lines);
如何在不添加任何符号的情况下创建新行