Pet*_*isu 5 cocoa objective-c nsattributedstring ios
iOS 上有 NSTextList 的等效项吗?
\n\n在 OSX 上我可以做
\n\nNSTextList *list = [[NSTextList alloc] initWithMarkerFormat:@"square" options:0];\nNSMutableParagraphStyle *paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];\n[paragraph setTextLists:[NSArray arrayWithObject:list]];\nNSTextTab *t1 = [[NSTextTab alloc] initWithType:0 location:11.0f];\nNSTextTab *t2 = [[NSTextTab alloc] initWithType:0 location:36.0f];\n[paragraph setTabStops:[NSArray arrayWithObjects:t1, t2, nil]];\nNSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:paragraph, NSParagraphStyleAttributeName, nil];\nNSString *string = @"\\t\xe2\x96\xaa\\tList item 1\\n\\t\xe2\x96\xaa\\tList item 2\\n\\t\xe2\x96\xaa\\tList item 3";\nNSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:string attributes:attributes];\nRun Code Online (Sandbox Code Playgroud)\n\n但 iOS 没有替代方案,因为所有解决方案都无法正常运行
\n我知道这是一个迟到的答案,但它可能对未来的人们有益。
是的,事实上你可以简单地使用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.
@interface或者,我认为您可以为您想要使用的 NSTextList 方法前向声明。