Xcode 11 Beta 5中的API更改后,如何在SwiftUI中为TextField使用RoundedBorderTextFieldStyle?

Leg*_*ang 1 beta xcode textfield swiftui

在Xcode 11 Beta 5之前,我使用以下语法在我的TextField外部放置了一个圆角边框:

TextField(“ Expression”,文本:$ expression).textFieldStyle(.roundedBorder)

可悲的是,这种方法已被弃用,现在给我警告。

新方法应该是:不推荐使用roundedBorder:RoundedBorderTextFieldStyle直接使用。

但是我想不出一种使用它的方法。

从开发人员文档中可以看出。RoundedBorderTextFieldStyle符合协议TextFieldStyle。

而且TextField似乎具有RoundedBorderTextFieldStyle作为嵌套结构?(不确定我是否理解正确,RoundedBorderTextFieldStyle写在开发人员文档的TextField下面)

我不知道如何使用新的RoundedBorderTextFieldStyle。

我正在寻找在Beta 5中编写以下代码的正确方法:

    TextField("Placeholder", text: $texts)
        .textFieldStyle(.roundedBorder)
Run Code Online (Sandbox Code Playgroud)

mat*_*att 8

你说:

 .textFieldStyle(RoundedBorderTextFieldStyle())
Run Code Online (Sandbox Code Playgroud)