【发布时间】:2017-11-09 06:35:15
【问题描述】:
attributedText数据结构如下
S{
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = "<UICTFont: 0x7fd82c717bc0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSOriginalFont = "<UICTFont: 0x7fd82c717bc0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSParagraphStyle = "Alignment 4, LineSpacing 2.90954, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 1, 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";
}hepi{
NSColor = "UIExtendedGrayColorSpace 0 1";
NSFont = "<UICTFont: 0x7fd82c717bc0> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 12.00pt";
NSParagraphStyle = "Alignment 4, LineSpacing 2.90954, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 1, 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";
}
我想保存一下,当用户重新打开应用时,可以在 UITextView 中再次看到这些(不会丢失颜色、字体大小等字体参数)
我尝试将它作为字符串保存到数据库,但我不能将它用于 UITextView 的属性化文本
另外它可能包含 UITextView 中的图片
我使用的数据库是 Realm 有什么方法可以实现吗?
如果可以的话,就拿上面的数据结构做一个demo,这样最好
【问题讨论】:
标签: ios objective-c realm uitextview nsattributedstring