HeG*_*eGe 5 keyboard toolbar ios swiftui ios17
自 iOS 17 起,工具栏中的某些功能不再起作用。
在此示例中,内容如下:
rotationEffect按钮标签上的、scaleEffect、rotationEffect3D、foregroundStyle和
foregroundColor可能更多内容在 iOS 17 中不起作用,但在 iOS 16 中具有正确的行为ToolbarItem(placement: .keyboard)不适用于 iOS 17,适用于 iOS 16这是最小的例子:
struct ContentView: View {
@State private var buttonRotation: CGFloat = 0
@State private var isActive: Bool = false
@State private var text: String = ""
var body: some View {
NavigationStack {
VStack {
Text("Hello, world!")
TextField("Text here", text: $text)
}
.padding()
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
Button(action: {
buttonRotation += 30
isActive.toggle()
}) {
Label("Info", systemImage: "info.circle")
// `rotationEffect` does not work in iOS 17, works in iOS 16
// the same for `scaleEffect`, `rotationEffect3D` and probably more
.rotationEffect(.degrees(buttonRotation))
// `foregroundStyle` & `foregroundColor` do not work in iOS 17, works in iOS 16
.foregroundStyle(isActive ? .purple : .accentColor)
}
// `tint` works in iOS 17 & 16
.tint(isActive ? .purple : .accentColor)
}
// `ToolbarItem(placement: .keyboard)` does not work in iOS 17, works in iOS 16
ToolbarItem(placement: .keyboard) {
Button(action: { }) {
Text("Button")
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果先单击 topBarTrailing 中的按钮,则 iOS 17 中将显示键盘,但如果先单击 Textfield,则不会显示键盘。
(第一张图片 iOS 16.2;第二张图片 iOS 17.0)
有谁知道解决方法?
我还在苹果论坛(https://developer.apple.com/forums/thread/740315)上发布了此内容并提交了反馈(FB13302279)
| 归档时间: |
|
| 查看次数: |
327 次 |
| 最近记录: |