如何清除swift中代码标签的内容?

How to clear the content of a label with code in swift?

我想在模拟器第一次启动时使用 swift 代码清除标签的内容,而不是使用 Xcode 的界面生成器。我怎么做?任何人都可以帮助我吗?谢谢!

使用这个,

yourLabel.text = ""

yourLabel.text = nil

您可以使用:

textLabel.text = nil

因为 textLabel.text 是可选字符串。