Thursday, November 12, 2026
HomeiOS Developmentswift - Change iOS SwiftUI Keyboard Extension Top

swift – Change iOS SwiftUI Keyboard Extension Top

[ad_1]

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 omit essential context. Moreover, since I am utilizing SwiftUI I am unsure that most 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() {
        tremendous.viewDidLoad()
        
        let keyboardController = UIHostingController(rootView: KeyboardWrapper())
        keyboardController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
        view.addSubview(keyboardController.view)
    }
}

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 foundation of the SwiftUI views, KeyboardWrapper. KeyboardWrapper then creates the Keyboard. This works as a strategy 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 adequate context for me to know precisely the place to place them within the code.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments