2013-10-18 18 views
6

Metin için elips yolum var. dolgu yolu için i NSMutableAttributedString kullandı:NSMutableAttributedString dikey bölüm

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

Ama sadece yatay metin hizalama için bu iş. Dikey bir şekilde nasıl uygulayabilirim?

ben bu sonucu vardır: enter image description here

Ama bu gerekir: enter image description here

cevap

0

Ama bu benim için iyi çalışıyor dikey ile çalıştık, Aşağıda ekran görüntüsü öyleyim varsa bana bildirin olduğunu yanlış ve ayrıca aşağıda ekli koddur: -

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

Soruyu güncelledim belki şimdi daha açık olacak –