Skip to content

Instantly share code, notes, and snippets.

@dwatson0101
dwatson0101 / AdaptsToSoftwareKeyboard.swift
Created July 9, 2020 18:41 — forked from scottmatthewman/AdaptsToSoftwareKeyboard.swift
An example of using Combine to automatically adapt a SwiftUI scrollable view to accommodate an iOS onscreen keyboard
import SwiftUI
import Combine
struct AdaptsToSoftwareKeyboard: ViewModifier {
@State var currentHeight: CGFloat = 0
func body(content: Content) -> some View {
content
.padding(.bottom, currentHeight)
.edgesIgnoringSafeArea(.bottom)