gpt4 book ai didi

ios - NSAttributedString 插入项目符号点?

转载 作者:IT王子 更新时间:2023-10-29 05:06:57 24 4
gpt4 key购买 nike

所以我有一个 NSAttributedString 我想在一段文本的开头插入一个 bullet point。我怎样才能做到这一点?如何创建一个 CTPAragraphStyle 来在我显示文本时创建这个项目符号点?

编辑:应该在 iOS

上可用

最佳答案

这是一种适用于 iOS6 的更现代的方法:

NSMutableAttributedString * string = [[NSMutableAttributedString alloc] initWithString:@"•\texample bullet fill out the text to check what happens on the second line and make sure it is lining up OK"];

NSMutableParagraphStyle *paragraphStyle;
paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[paragraphStyle setTabStops:@[[[NSTextTab alloc] initWithTextAlignment:NSTextAlignmentLeft location:15 options:nil]]];
[paragraphStyle setDefaultTabInterval:15];
[paragraphStyle setFirstLineHeadIndent:0];
[paragraphStyle setHeadIndent:15];

[string addAttributes:@{NSParagraphStyleAttributeName: paragraphStyle} range:NSMakeRange(0,[string length])];

关于ios - NSAttributedString 插入项目符号点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6644501/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com