菜鸟教程小白 发表于 2022-12-11 19:38:45

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 = &#34;,&#34;

// Events
tagsField.onDidAddTag = { _ in
    print(&#34;DidAddTag&#34;)
}

tagsField.onDidRemoveTag = { _ in
    print(&#34;DidRemoveTag&#34;)
}

tagsField.onDidChangeText = { _, text in
    print(&#34;DidChangeText&#34;)
}

tagsField.onDidBeginEditing = { _ in
    print(&#34;DidBeginEditing&#34;)
}

tagsField.onDidEndEditing = { _ in
    print(&#34;DidEndEditing&#34;)
}

tagsField.onDidChangeHeightTo = { sender, height in
    print(&#34;HeightTo \(height)&#34;)
}
</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]
查看完整版本: ios - 我想使用 swift 添加标签或文本,如下图所示