HomeiOS DevelopmentiOS 26 SwiftUI app when keyboard is proven, the keyboard's toolbar covers...

iOS 26 SwiftUI app when keyboard is proven, the keyboard’s toolbar covers the textual content enter (it labored on iOS 18)


When I’ve a textual content subject on backside of a listing, then faucet on it to point out the keyboard that has a toolbar button, on iOS 26, the keyboard’s toolbar covers the textual content subject:

iOS 26 SwiftUI app when keyboard is proven, the keyboard’s toolbar covers the textual content enter (it labored on iOS 18)

Nevertheless, it labored tremendous on iOS 18. I ponder if the keyboard is reporting a peak that does not embody the toolbar on iOS 26 anymore?

Check out this reproducible code:

import SwiftUI

struct ContentView: View {
  @State var textual content: String = ""
  var physique: some View {
    NavigationStack {
      Checklist {
        
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        Textual content("Hi there, world!").font(Font.system(measurement: 32))
        
        TextField("Click on Me", textual content: $textual content)
        
      }
      .toolbar {
        ToolbarItemGroup(placement: .topBarLeading) {
          Button {
            
          } label: {
            Textual content("Toggle")
          }
        }
      }
      .toolbar {
        ToolbarItemGroup(placement: .keyboard) {
          keyboardButtons
        }
      }
    }
    .navigationTitle("Hi there")
  }
  
  @ViewBuilder
  non-public var keyboardButtons: some View {

    HStack {
      SUITextButton("Button1234") {}
      Spacer()
      
      
      SUIImageButton(
        picture: UIImage(
          systemName: "chevron.left",
          withConfiguration: UIImage.SymbolConfiguration(pointSize: 32, weight: .common, scale: .small)
        )!,
        enabled: true
      ) {}

      Spacer()


      SUIImageButton(
        picture: UIImage(
          systemName: "chevron.proper",
          withConfiguration: UIImage.SymbolConfiguration(pointSize: 32, weight: .common, scale: .small)
        )!,
        enabled: true
      ) {}

      Spacer()
      SUITextButton("Button1234") {}
    }
  }
}

#Preview {
  ContentView()
}

public struct SUITextButton: View {
  
  non-public let title: String
  non-public let motion: () -> Void
  non-public let enabled: Bool
  
  public init(_ title: String, enabled: Bool = true, motion: @escaping () -> Void) {
    self.title = title
    self.enabled = enabled
    self.motion = motion
  }
  
  public var physique: some View {
    Button(title, motion: motion)
  }
}

public struct SUIImageButton: View {
  
  public init(picture: UIImage, enabled: Bool, motion: @escaping () -> Void) {
    self.picture = picture
    self.enabled = enabled
    self.motion = motion
  }
  
  non-public let picture: UIImage
  non-public let enabled: Bool
  non-public let motion: () -> Void
  
  public var physique: some View {
    Button(motion: motion) {
      SUIImage(
        uiImage: picture,
        // Because it's inside a button, will probably be blue when enabled, and grey when disabled.
        rendering: .systemTint)
    }
  }
  
}

public struct SUIImage: View {
  
  public enum Rendering {
    // template mode
    // In buttons, blue if enabled, grey if disabled
    // In any other case (e.g. textual content), black if mild mode, white if darkish mode
    case systemTint
    // template mode + foreground colour (e.g. magic merchandise with overlay)
    case customColor(colour: UIColor)
    // authentic mode (e.g. magic merchandise with out overlay)
    case authentic
  }
  
  
  non-public let uiImage: UIImage
  non-public let rendering: Rendering

  public init(uiImage: UIImage, rendering: Rendering) {
    self.uiImage = uiImage
    self.rendering = rendering
  }
  
  public var physique: some View {
    
    let width: CGFloat = 19.0 + (2.0 / 3.0)
    let peak: CGFloat = 26.0 + (2.0 / 3.0)
    
    Picture(uiImage: uiImage)
      .renderingMode(.template)
//      .body(width: width, peak: peak)
//      .body(minWidth: 19)
//      .body(width: width.rounded() + .pi, peak: peak.rounded() + .pi)
  }
}

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments