Since iOS 17, certain things in the toolbar do not work anymore.
In this example it is the following:
-
rotationEffect
;scaleEffect
,rotationEffect3D
,foregroundStyle
,foregroundColor
and probably more on a button label do not work in iOS 17 but have the correct behavior in iOS 16 -
ToolbarItem(placement: .keyboard)
does not work in iOS 17, works in iOS 16
Here is the minimal example:
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")
}
}
}
}
}
}
If the button in the topBarTrailing is clicked first, the keyboard will show up in iOS 17, but not if the Textfield is clicked first.
Filed a feedback (FB13302279)