2013-10-18 11 views
6

私はテキストの楕円のパスを持っています。フィルパスiについてNSMutableAttributedStringを使用: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]; 

しかし、唯一の水平方向のテキスト配置のため、この作品。私はどのように縦方向のアライメントを適用できますか?

私はこの結果を持っている: enter image description here

をしかし、私はこの必要があります。 enter image description here

答えて

0

をしかし、私はそれが私のために正常に動作している垂直で試してみましたが、下のスクリーンショットは、私があれば、私は を教えてくださいです間違っても以下に添付のコードは次のとおりです。 -

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

質問が更新されました –

関連する問題