KSWXRichTextComponent 0.0.1

KSWXRichTextComponent 0.0.1

HJaycee维护。



  • HJaycee

介绍

本仓库是 iOS 端的 weex 富文本组件。本质上是一个 UITextView,用于将 HTML 字符串解析成 NSAttributedString

但是,并不是所有 HTML 样式都能被解析出来,比如 圆角渐变边框 等。

本组件对这些特殊样式也做了支持,并支持自定义 超链接颜色文字行数获取 等扩展功能。

Cocoapods

pod 'KSWXRichTextComponent'

效果演示

example.png

如何使用

1.原生中注册组件

[WXSDKEngine registerComponent:@"rich-text" withClass:[KSWXRichTextComponent class]];

2.前端中使用组件

<rich-text class="rich" text="<p style='color:blue;'>abc</p>"></rich-text>

.rich {
	color: red;
}

外部样式(class)

color: ;
fontFamily: ;
fontSize: ;
textAlign: ;
lineHeight: ;
paddingLeft: ;
paddingRight: ;
paddingTop: ;
paddingBottom: ;
letterSpacing: ;
textOverflow: ; // only ellipsis
lines: ;

内部样式(style)

支持所有样式,但是并不是都会被解析出来,比如 圆角相关样式

圆角相关样式(style)

  • 具有border样式的