Sunday, August 14, 2022
HomeiOS Developmentswift - Change iOS SwiftUI Keyboard Extension Top

swift – Change iOS SwiftUI Keyboard Extension Top

I’ve seen potential duplicates of this query however none of them appear to have a minimal reproducible instance and have small snippets of code that miss vital context. Moreover, since I am utilizing SwiftUI I am unsure that lots of the solutions apply.

I’m utilizing SwiftUI to construct an iOS keyboard extension. Right here is the related code:

import UIKit
import SwiftUI

class KeyboardViewController: UIInputViewController {
    override func viewDidLoad() {
        let keyboardController = UIHostingController(rootView: KeyboardWrapper())
        keyboardController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]

struct KeyboardWrapper: View {
    var physique: some View {
        GeometryReader { rect in
            Keyboard(rect: rect)

The foundation of my keyboard extension is at KeyboardViewController, which provides as a subview a UIHostingController that wraps the basis of the SwiftUI views, KeyboardWrapper. KeyboardWrapper then creates the Keyboard. This works as a method to arrange a keyboard that has the identical peak because the system keyboard, as proven right here:

system-height keyboard

My query is how can I modify the peak of my keyboard? I’ve seen the posts round including constraints however once more they lack enough context for me to know precisely the place to place them within the code.



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments