2013-10-18 23 views
6

Ich habe einen Ellipsenpfad für Text. Für Füllpfad verwendet i NSMutableAttributedString:NSMutableAttributedString vertikale Ausrichtung

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

Aber diese Arbeit nur für die horizontale Textausrichtung. Wie kann ich vertikale Ausrichtung anwenden?

ich dieses Ergebnis haben: enter image description here

Aber ich brauche diese: enter image description here

Antwort

0

Aber ich habe versucht, mit vertikalem es für mich funktioniert gut, unten ist das Screenshot mich wissen lassen, wenn ich bin falsch und unten ist auch der Code angehängt: -

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

Ich habe die Frage aktualisiert vielleicht jetzt wird klarer –