WSTagsFieldiOS 文本标签工具
WSTagsField 是采用swift开发的,用于给文字添加标签样式。
效果图:
使用环境:
-
iOS 8.0+
-
Xcode 7 (Swift 2.2)
示例代码:
let tagsField = WSTagsField() tagsField.backgroundColor = .whiteColor() tagsField.padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) tagsField.spaceBetweenTags = 10.0 tagsField.font = UIFont.systemFontOfSize(12.0) tagsField.tintColor = .greenColor() tagsField.textColor = .blackColor() tagsField.fieldTextColor = .blueColor() tagsField.selectedColor = .blackColor() tagsField.selectedTextColor = .redColor() tagsField.delimiter = "," // Events tagsField.onDidAddTag = { _ in print("DidAddTag") } tagsField.onDidRemoveTag = { _ in print("DidRemoveTag") } tagsField.onDidChangeText = { _, text in print("DidChangeText") } tagsField.onDidBeginEditing = { _ in print("DidBeginEditing") } tagsField.onDidEndEditing = { _ in print("DidEndEditing") } tagsField.onDidChangeHeightTo = { sender, height in print("HeightTo \(height)") }
评论