iOS 中的 NSTextList

问题描述 投票:0回答:1

iOS 上有 NSTextList 的等效项吗?

在 OSX 上我可以做

NSTextList *list = [[NSTextList alloc] initWithMarkerFormat:@"square" options:0];
NSMutableParagraphStyle *paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraph setTextLists:[NSArray arrayWithObject:list]];
NSTextTab *t1 = [[NSTextTab alloc] initWithType:0 location:11.0f];
NSTextTab *t2 = [[NSTextTab alloc] initWithType:0 location:36.0f];
[paragraph setTabStops:[NSArray arrayWithObjects:t1, t2, nil]];
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:paragraph, NSParagraphStyleAttributeName, nil];
NSString *string = @"\t▪\tList item 1\n\t▪\tList item 2\n\t▪\tList item 3";
NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string attributes:attributes];

但是 iOS 没有替代方案,因为所有解决方案都无法正确运行

ios objective-c cocoa nsattributedstring
1个回答
0
投票

我知道这是一个迟来的答案,但它可能对未来的人们有益。

是的,事实上您可以简单地使用

NSTextList
本身。

事实证明,NSTextList 至少从 iOS 7 起就已包含在 iOS 中(请参阅 Apple 文档iOS 标头转储)。

但是,直到 iOS 16 之前它因为某种原因一直没有出现在 SDK 中。

简单来说,您所要做的就是将标头从包含该标头的 SDK 复制到

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS15.5.sdk/System/Library/Frameworks/UIKit.framework/Headers

© www.soinside.com 2019 - 2024. All rights reserved.