Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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 如何在Objective c中生成多行曲线文本_Objective C_Xcode_Core Text - Fatal编程技术网

Objective c 如何在Objective c中生成多行曲线文本

Objective c 如何在Objective c中生成多行曲线文本,objective-c,xcode,core-text,Objective C,Xcode,Core Text,我想用多行制作曲线文本 我使用了“CoreTextArcView.h”和“CoreTextArcView.m”文件,我发现其中一个文件可以生成曲线文本,但当我尝试按以下方式为多行曲线文本键入类似“Hello\nWald”的字符串时 CGRect rect1 = CGRectMake(0, 120, 320, 120); UIFont * font1 = [UIFont fontWithName:@"Helvetica" size:26.0f]; UIColor * color1 = [UICo

我想用多行制作曲线文本

我使用了“CoreTextArcView.h”和“CoreTextArcView.m”文件,我发现其中一个文件可以生成曲线文本,但当我尝试按以下方式为多行曲线文本键入类似“Hello\nWald”的字符串时

CGRect rect1 = CGRectMake(0, 120, 320, 120);
UIFont * font1 = [UIFont fontWithName:@"Helvetica" size:26.0f]; 
UIColor * color1 = [UIColor whiteColor];
CoreTextArcView * cityLabel = [[[CoreTextArcView alloc] initWithFrame:rect1
                                                            font:font1
                                                            text:@"Hello\nWorld"
                                                          radius:85
                                                         arcSize:110
                                                           color:color1] autorelease];
cityLabel.backgroundColor = [UIColor clearColor];

[self.view addSubview:cityLabel];
但结果只显示一行曲线文本,就像我键入的“Hello\nWalrd”一样,不影响多行效果

我想要这样:


在上面的自定义类中,直接使用新行文本是不可能的,但您应该添加一些逻辑,并按照下面的方式进行计算

UIFont * font1 = [UIFont fontWithName:@"Helvetica" size:26.0f];
UIColor * color1 = [UIColor blackColor];

NSString *titleString = @"Hello\nWorld";
NSArray *strArray = [titleString componentsSeparatedByString:@"\n"];

int y = 120;
for (NSString *strCurveText in strArray) {
     CGRect rect1 = CGRectMake(0, y, 320, 70);
     CoreTextArcView * cityLabel = [[CoreTextArcView alloc] initWithFrame:rect1
                                                                        font:font1
                                                                        text:strCurveText
                                                                      radius:35
                                                                     arcSize:90
                                                                       color:color1];
      cityLabel.backgroundColor = [UIColor clearColor];

      [self.view addSubview:cityLabel];

      y = y + (rect1.size.height/2);
  }
根据文本大小设置圆弧大小半径


希望这能对您有所帮助。

在上面的自定义类中,直接使用新行文本是不可能的,但您应该添加一些逻辑,并按照下面的方式进行计算

UIFont * font1 = [UIFont fontWithName:@"Helvetica" size:26.0f];
UIColor * color1 = [UIColor blackColor];

NSString *titleString = @"Hello\nWorld";
NSArray *strArray = [titleString componentsSeparatedByString:@"\n"];

int y = 120;
for (NSString *strCurveText in strArray) {
     CGRect rect1 = CGRectMake(0, y, 320, 70);
     CoreTextArcView * cityLabel = [[CoreTextArcView alloc] initWithFrame:rect1
                                                                        font:font1
                                                                        text:strCurveText
                                                                      radius:35
                                                                     arcSize:90
                                                                       color:color1];
      cityLabel.backgroundColor = [UIColor clearColor];

      [self.view addSubview:cityLabel];

      y = y + (rect1.size.height/2);
  }
根据文本大小设置圆弧大小半径


希望这能对您有所帮助。

您能告诉我们您想要多行的哪种输出吗?因为曲线文本通常是单行的,带有圆角文本。我添加了输出,即我想要@codechanger你能解决它吗?你能告诉我们你想要多行的哪种输出吗?因为曲线文本通常是单行的,带有圆角文本。我添加了输出,我希望@codechanger您能解决它吗