我有一个文本的椭圆路径。对于填充路径,我使用了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];但这只适用于水平文本对齐。如何应用垂直对齐?
我有这样的结果:

但我需要这个:

发布于 2013-10-18 13:56:41
但我已经尝试了垂直它是工作很好的我,下面是截图让我知道如果我错了,也是下面的代码附件:--

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];https://stackoverflow.com/questions/19441972
复制相似问题