7

I have a ellipse path for text. For fill path I used NSMutableAttributedString:

UIFont *font = [UIFont fontWithName:@"font name" size:15];
NSMutableParagraphStyle *mutParaStyle=[[NSMutableParagraphStyle alloc] init];

[mutParaStyle setAlignment:NSTextAlignmentCenter];
[mutParaStyle setLineBreakMode:NSLineBreakByWordWrapping];

NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:font
                                 ,NSFontAttributeName,mutParaStyle ,NSParagraphStyleAttributeName,nil]; 

NSMutableAttributedString  *strText = [[NSMutableAttributedString alloc] initWithString:text attributes:attrsDictionary];

But this work only for horizontal text alignment. How i can apply vertical aligment?

I have this result: enter image description here

But I need this: enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267
bpa
  • 183
  • 1
  • 12

1 Answers1

0

But i have tried with vertical it is working fine for me, Below is the screenshot Let me know if i am wrong and also below is the code attached:--

enter image description here

NSString *allTheText = [tv string];
NSFont *font = [NSFont fontWithName:@"Helvetica" size:24];
NSMutableParagraphStyle *mutParaStyle=[[NSMutableParagraphStyle alloc] init];

[mutParaStyle setAlignment:kCTTextAlignmentRight];
[mutParaStyle setLineBreakMode:NSLineBreakByWordWrapping];

NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:font
                                 ,NSFontAttributeName,mutParaStyle ,NSParagraphStyleAttributeName,nil];

NSMutableAttributedString  *strText = [[NSMutableAttributedString alloc] initWithString:allTheText attributes:attrsDictionary];
[tv .textStorage appendAttributedString:strText];
Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56