ios - 我想使用 swift 添加标签或文本,如下图所示
<p><p> <img src="/image/BUjtD.png" alt="Image"/> </p>
<p>点击某些按钮后,按钮的标题应显示为带有“X”标记的标签或文本,单击“X”后,文本应从搜索栏中消失。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>这对你有帮助。</p>
<pre><code>let tagsField = WSTagsField()
tagsField.backgroundColor = .white
tagsField.padding = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
tagsField.spaceBetweenTags = 10.0
tagsField.font = .systemFont(ofSize: 12.0)
tagsField.tintColor = .green
tagsField.textColor = .black
tagsField.fieldTextColor = .blue
tagsField.selectedColor = .black
tagsField.selectedTextColor = .red
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)")
}
</code></pre>
<p> <a href="https://github.com/whitesmith/WSTagsField/blob/master/README.md" rel="noreferrer noopener nofollow">https://github.com/whitesmith/WSTagsField/blob/master/README.md</a> </p></p>
<p style="font-size: 20px;">关于ios - 我想使用 swift 添加标签或文本,如下图所示,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/48377794/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/48377794/
</a>
</p>
页:
[1]