OStack程序员社区-中国程序员成长平台

标题: ios - 我想使用 swift 添加标签或文本,如下图所示 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 19:38
标题: ios - 我想使用 swift 添加标签或文本,如下图所示

Image

点击某些按钮后,按钮的标题应显示为带有“X”标记的标签或文本,单击“X”后,文本应从搜索栏中消失。



Best Answer-推荐答案


这对你有帮助。

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)")
}

https://github.com/whitesmith/WSTagsField/blob/master/README.md

关于ios - 我想使用 swift 添加标签或文本,如下图所示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48377794/






欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) Powered by Discuz! X3.4