2013-10-18 7 views
6

Ho un percorso di ellisse per il testo. Per percorso di riempimento ho usato NSMutableAttributedString:NSMutableAttributedString aligment verticale

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

Ma questo lavoro solo per l'allineamento del testo orizzontale. Come posso applicare l'aligment verticale?

ho questo risultato: enter image description here

Ma ho bisogno di questo: enter image description here

risposta

0

Ma ho provato con verticale si sta lavorando bene per me, Di seguito è riportato lo screenshot Fammi sapere se io sono sbagliato e anche al di sotto è il codice allegato: -

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

ho aggiornato la domanda forse ora sarà più chiaro –