Skip to content

Instantly share code, notes, and snippets.

View lukepistrol's full-sized avatar

Lukas Pistrol lukepistrol

View GitHub Profile
@juliensagot
juliensagot / HostingView.swift
Created June 21, 2024 14:22
The missing UIHostingView
import SwiftUI
import UIKit
public final class HostingView: UIView {
public init(@ViewBuilder content: () -> some View) {
super.init(frame: .zero)
let contentView = UIHostingConfiguration(content: content)
.margins(.all, 0)
.makeContentView()
@sebjvidal
sebjvidal / ViewController.swift
Created May 28, 2024 16:39
UICustomViewMenuElement Demo
//
// ViewController.swift
// UIMenu-Demo
//
// Created by Seb Vidal on 28/05/2024.
//
import UIKit
class ViewController: UIViewController {
@kyungpyoda
kyungpyoda / CodableInheritanceExample.swift
Created May 28, 2021 01:17
[Swift] Codable class and inheritance
//
// CodableInheritanceExample.swift
//
// Created by 홍경표 on 2021/05/28.
//
class BaseResponse: Codable {
var retCode: Int = 0
private enum CodingKeys: String, CodingKey {
@scriptpapi
scriptpapi / DocumentPicker.swift
Created April 26, 2021 21:25
Document Picker for SwiftUI
import Foundation
import SwiftUI
import UIKit
struct DocumentPicker: UIViewControllerRepresentable {
@Binding var filePath: URL?
func makeCoordinator() -> DocumentPicker.Coordinator {
return DocumentPicker.Coordinator(parent1: self)
import Foundation
public class CodableStorage {
fileprivate init() { }
enum Directory {
case documents
case caches
case shared // Use for sharing files between containers. Eg, with an app extension.
@verebes1
verebes1 / ColorSupport.swift
Last active August 18, 2021 19:09
Using UIColors from iOS13 with backward compatibility to previous iOS versions.
import UIKit
public enum ColorSupport {
public static var label: UIColor {
if #available(iOS 13, *) {
return .label
}
return UIColor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)
}