ChainedAttributedString 2.0.0

ChainedAttributedString 2.0.0

测试已测试
语言语言 SwiftSwift
许可 MIT
发布最后发布2016年9月
SPM支持 SPM

Adam Szeremeta 维护。



  • Adam Szeremeta

ChainedAttributedString

在 Swift 中创建属性字符串的简单易用方式

Screenshot

目录

特性

特性

  • 通过调用 .attributedString() 从普通字符串创建属性字符串
  • 使用 + 运算符连接多个属性字符串
  • 将多个属性依次附加到字符串的整个或部分上

支持的属性

  • 文本字体
  • 文本颜色
  • 文本背景颜色
  • 字距
  • 删除线样式和颜色
  • 下划线样式和颜色
  • 链接

安装

首选方法是使用 CocoaPods

use_frameworks!
pod 'ChainedAttributedString', '~> 1.0.0'

如果您由于某种原因无法使用 CocoaPods,则请从 ChainedAttributedString/ 拉取文件并将其放入您的项目中。

用法

只需通过调用 import ChainedAttributedString 导入库即可,现在您可以开始使用了!

示例操作

import ChainedAttributedString

//join strings
let one = "Test".attributedString() + "One".attributedString()

//apply attributes
self.exampleLabel.attributedText = "This sample text shows chained attributes".attributedString()
.textColor(UIColor.redColor(), forText: "sample")
.font(UIFont.boldSystemFontOfSize(20), forText: "This")
.kernSpacing(-1, forText: "text")
.strikeThrough(2, forText: "shows")
.strikeThroughColor(UIColor.blueColor())
.underline(2, forText: "attributes")

作者

adamszeremeta, [email protected]

许可

ChainedAttributedString 在 MIT 许可下发布。