Skip to content

Instantly share code, notes, and snippets.

View TomQDRS's full-sized avatar
🏳️‍🌈

TomQDRS TomQDRS

🏳️‍🌈
  • Münster, Germany
View GitHub Profile
@TomQDRS
TomQDRS / ExpandableText.swift
Created August 6, 2021 14:30
Wraps a SwiftUI Text View in a VStack and offers a Button that toggles an expanded state by changing the maximum number of lines.
//
// ExpandableText.swift
//
// Created by TomQDRS on 06.08.21.
//
import SwiftUI
extension Text {
@TomQDRS
TomQDRS / KeyboardSpaceManagement.swift
Last active January 9, 2019 09:53
This piece of code should help you if the iOS keyboard hides essential views upon being shown.
// SETUP REQUIRED:
// The setup requires a Storyboard setup with an empty, clear view called `keyboardSpacer`.
// That view should be placed below the elements that you want to be pushed up when the keyboard appears.
// Give that view a height constraint and connect that constraint to `keyboardSpacerHeightConstraint`.
// The static value for that height (thes size when the keyboard isn't shown) should be jotted down in `staticHeightForKeyboardSpacer`.
// This can also be simplified by making `staticHeightForKeyboardSpacer` inspectable.
// The following functions will change the height constraint of the `keyboardSpacer` view depending on the keyboard status,
// making sure that the spacer view will be the same height as the keyboard when it is shown or changed and revert to the original size when it is hidden.