美文网首页
2019-03-08

2019-03-08

作者: 腾_cb47 | 来源:发表于2019-03-11 13:57 被阅读0次

NStextview note:

we use textview for collecting the logs from terminal or equipment port .

NSAttributedstring *attributedstr = [NSAttributedString alloc] initiwithstring:(NSString *)str attributes:(NSMutableDictionary *)dic];

[textview textstorage] appendattributedstring:(NSAttributedstring *) attributedstring;     --appendstr

code:

NSString *str = @"hello, soelsdkfj sld sodfl asl a我饿谁说大幅拉升哦 is 快乐的佛 i 阿斯科利大事佛阿胶alkydi 哦啊时间来考试的offer流口水的麻烦i 哦文件佛拉风i 就哦 i 啊三闾大夫破额外附加";

    NSMutableDictionary *dic = [NSMutableDictionary dictionaryWithCapacity:2];

    [dicsetObject:[NSColor redColor] forKey:NSForegroundColorAttributeName];

    [dicsetObject:[NSColor blueColor] forKey:NSBackgroundColorAttributeName];

    NSAttributedString *attri = [[NSAttributedString alloc] initWithString:str attributes:dic];

    [[_textview textStorage] appendAttributedString:attri];

相关文章

网友评论

      本文标题:2019-03-08

      本文链接:https://www.haomeiwen.com/subject/kjddpqtx.html