我有一个文本视图,其中包含黑色和蓝色文本。现在我需要通过向每个文本添加特殊标记(__BLACK__ and __BLUE__
)将其传递给服务器。因此,如果我的文字是,例如在下面的图像中
发送字符串应为__BLUE__Hi__/BLUE__ __BLACK__this__/BLACK__ __BLUE__is__/BLUE__ __BLACK__John__/BLACK__
所以,当我从服务器上取回它时,我可以识别哪些是黑色和蓝色,并为其应用属性。
目前,如果我打印属性字符串的描述,它将在下面显示
Hi {
NSColor = "UIExtendedSRGBColorSpace 0 0 1 1";
NSFont = "<UICTFont: 0x7ffbdfd10ce0> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (\n), Lists (\n), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0";
}this {
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = "<UICTFont: 0x7ffbdfd10ce0> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (\n), Lists (\n), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0";
}is {
NSColor = "UIExtendedSRGBColorSpace 0 0 1 1";
NSFont = "<UICTFont: 0x7ffbdfd10ce0> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (\n), Lists (\n), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0";
}John{
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = "<UICTFont: 0x7ffbdfd10ce0> font-family: \".SFUIText\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 4, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n 28L,\n 56L,\n 84L,\n 112L,\n 140L,\n 168L,\n 196L,\n 224L,\n 252L,\n 280L,\n 308L,\n 336L\n), DefaultTabInterval 0, Blocks (\n), Lists (\n), BaseWritingDirection -1, HyphenationFactor 0, TighteningForTruncation NO, HeaderLevel 0";
}
如何识别哪个文本应标记为__BLACK__ and __BLUE__
?