FTCoreText

来源:互联网 发布:mac淘宝上传工具 编辑:程序博客网 时间:2024/06/05 05:24

FTCoreText

An open source Objective-C interface component that makes use of the CoreText framework to render static text content using a highly customisable markup syntax.

FTcoreText 是一个开源的 OC 组件,使用了 CoreText 框架来渲染静态文本,具备很高的可定制性。

 

 

Use FTCoreTextView

1. Import FTCoreText(引入头文件

#import FTCoreTextView.h

2. Create an instance of FTCoreTextView(创建一个实例变量

3. Create styles to apply to the output by creating instances of FTCoreTextStyle(创建一个样式的实例变量

//  Draw text closed in <red> tag in red color//  Example: <red>this will be drawn red</red>FTCoreTextStyle *redStyle = FTCoreTextStyle *imageStyle = [FTCoreTextStyle styleWithName:@"red"];redStyle.color = [UIColor redColor];

4. Once styles are defined, apply them to the view:(将定义好的样式赋给view

[ftCoreTextInstance addStyles:@[style1, style2, style3]];

5. Set text with corrent markdown to the FTCoreTextView instance(给FTCoreTextView中的实例对象设置正确的标签

ftCoreTextInstance.text = @"My text with <red>red</red> word.";

See the included examples project highlighting various features.

看看demo就知道怎么用了。

Elements

FTCoreText provides some interface element types for rendering content types commonly found on the web and printed media such as lists, images, links and suchlike.

FTCoreText 提供了很多种类型的接口用来渲染常见的文本,诸如在网页上看到的或者印刷的媒体如列表,图片,链接之类的。

Included:

包含:

  • FTCoreTextTagDefault: the default style applied to the text.普通文本
  • FTCoreTextTagPage: Divide the text in pages. Markup: <_page/>分页
  • FTCoreTextTagBullet: define styles for bullets. Markup: <_bullet>content</bullet>.加粗
  • FTCoreTextTagImage: renders images. Markup: <_image>imageNameOnBundle.extension</_image>显示图片
  • FTCoreTextTagLink: define style for links. Markup: <_link>link_target|link - name</_link>. SeeFTCoreTextViewDelegate for responding to touch.链接地址

To use the included element types, set the name of an FTCoreTextStyle style instance to one of the string constant types above and use the markup specified. Example: linkTypeFTCoreTextStyleInstance.name = FTCoreTextTagLink, and in the static content: <_link>http://fuerteint.com|Fuerte International</_link>

为了使用这些要素,设置 FTCoreTextStyle 的实例变量的样式为上面中的一种,然后再用特殊标示符即可。

Notes

  1. Use of the CoreText framework is available for iOS versions 3.2 and above.

  2. Although FTCoreTextView uses a similar markup syntax to HTML, most of the properties defined in the HTML specification are unsupported.

  3. 支持 CoreText 框架的 iOS 版本为 3.2 以上。
  4. 虽然 FTCoreTextView 提供了一个类似 HTML 的标签语言,但是,在 HTML 中定义的绝大部分语法是不支持的。
0 0
原创粉丝点击