2013-10-18 16 views
6

Mam ścieżkę elipsy dla tekstu. Na ścieżce wypełnienia użyłem NSMutableAttributedString:NSMutableAttributedString vertical aligment

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

Ale to praca tylko dla poziomego wyrównania tekstu. Jak mogę zastosować pionowe aligment?

mam ten wynik: enter image description here

ale muszę to: enter image description here

Odpowiedz

0

ale próbowałem z pionową to działa dobrze dla mnie, Poniżej znajduje się zrzut ekranu Daj znać jeśli jestem źle, a także poniżej jest kod załączeniu: -

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

Zaktualizowałem pytanie, może teraz będzie jaśniejsze –

Powiązane problemy