本文介绍了Markdown到NSAttributedString库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在iOS 6中完全支持NSAttributedString,是否有一个带有markdown的NSString库,并将其转换为NSAttributedString?

Now that NSAttributedString is fully supported in iOS 6, is there a library that will take an NSString with markdown, and convert it to NSAttributedString?

推荐答案

我刚刚将 NSString 添加到 NSAttributedString 轻量级标记解析器到。这不是Markdown,但它非常相似。到目前为止,它支持粗体,斜体,下划线,单声道,文本颜色,背景颜色和字距调整。

I've just added an NSString to NSAttributedString lightweight markup parser to MGBoxKit. It's not Markdown but it's very similar. So far it supports bold, italics, underline, monospacing, text colour, background colour, and kerning.

类现在是一个独立的pod,所以可以很容易地独立于MGBoxKit使用。

The MGMushParser class is now a standalone pod, so can easily be used independent of MGBoxKit.

NSString *markup = @"**bold**, //italics//, __underlining__, `monospacing`, and {#0000FF|text colour}";

UIFont *baseFont = [UIFont fontWithName:@"HelveticaNeue" size:18];
UIColor *textColor = UIColor.whiteColor;

myLabel.attributedString = [MGMushParser attributedStringFromMush:markup
                               font:baseFont color:textColor];

这篇关于Markdown到NSAttributedString库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 07:42