1

I want to make curved text with Multiple line.

I have used "CoreTextArcView.h" & "CoreTextArcView.m" file which one i found to make curving text but when i have tried as following to type string like "Hello\nWolrd" for multi line curve text

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];

But result display only one line curved text same as I have typed like "Hello\nWolrd" not effected to multiline effect.

I Want like this:

enter image description here

Subhash Khimani
  • 427
  • 7
  • 22

1 Answers1

0

Direct with New Line Text is not possible in above Custom class but you should put some logic and work it out like below.

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);
  }

Set ArcSize and radius as per your text size.

Hope this will helps you.

CodeChanger
  • 7,953
  • 5
  • 49
  • 80