Pav*_*rev 6 objective-c ios 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];
Run Code Online (Sandbox Code Playgroud)
但这只适用于水平文本对齐.我如何应用垂直对齐?
我有这个结果:

但我需要这个:

但我尝试过垂直,它对我来说工作得很好,下面是屏幕截图,如果我错了,请告诉我,下面是附加的代码:--

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];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1546 次 |
| 最近记录: |