【发布时间】:2019-12-10 13:14:48
【问题描述】:
在 Xcode 11 Beta 5 之前。我使用这种语法在我的 TextField 之外放置一个圆形边框:
TextField("Expression", text: $expression)
.textFieldStyle(.roundedBorder)
遗憾的是,这种方法已被弃用,现在给我警告。
新方法应该是:roundedBorder' 已弃用:直接使用RoundedBorderTextFieldStyle。
但我不知道如何使用它。
从开发者文档中我可以看出。 RoundedBorderTextFieldStyle 符合 TextFieldStyle 协议。
而且 TextField 似乎有 RoundedBorderTextFieldStyle 作为嵌套结构?(不确定我是否理解正确,RoundedBorderTextFieldStyle 写在开发者文档中 TextField 下方)
我不知道如何使用新的 RoundedBorderTextFieldStyle。
我正在寻找在 Beta 5 中编写以下代码的正确方法:
TextField("Placeholder", text: $texts)
.textFieldStyle(.roundedBorder)
【问题讨论】:
标签: xcode textfield swiftui beta