Post

Replies

Boosts

Views

Activity

SwiftUI keyboard safe area not ignored completely
I'm not sure if I'm doing something wrong here, but it looks so trivial that it feels like a bug to me. Ideally the entire view shouldn't move once the keyboard appears, but it still does when the green rectangle is tall enough. struct ContentView: View {   var body: some View {     return VStack {       TextField("Email address", text: Binding.constant(""))       Rectangle().fill(Color.green).frame(height: 500)       Spacer()     }     .overlay(GeometryReader { geo in Text(verbatim: "\(geo.frame(in: .global))").frame(maxHeight: .infinity) })     .border(Color.red, width: 2)     .ignoresSafeArea(.keyboard, edges: .all)   } } I put the GeometryReader overlay so I can observe the actual frame size of the entire view. After little experimentation I can conclude that when the ignoresSafeArea is enabled the view effectively goes under the keyboard but the top edge is still lifted the same amount of pixels it would be moved if the safe area is not disabled. The frame actually becomes larger when the keyboard appears! Making the green rectangle smaller makes the problem disappears as soon as it fits within the visible area when the keyboard appears.
2
0
3.3k
Sep ’20