Skip to content

Instantly share code, notes, and snippets.

View stleamist's full-sized avatar

Dongkyu “Max” Kim stleamist

View GitHub Profile
@simonbs
simonbs / SwiftUIHostingConfiguration.md
Last active March 9, 2025 17:09
In iOS 16, Apple added UIHostingConfiguration, making it straightforward to use a SwiftUI view in instances of UICollectionViewCell and UITableViewCell. This project shows how UIHostingConfiguration can be backported to iOS 14 by implementing a type that conforms to the UIContentConfiguration protocol.

SwiftUIHostingConfiguration

In iOS 16, Apple added UIHostingConfiguration, making it straightforward to use a SwiftUI view in instances of UICollectionViewCell and UITableViewCell. This gist shows how UIHostingConfiguration can be backported to iOS 14 by implementing a type that conforms to UIContentConfiguration.

Starting from iOS 16, we can use SwiftUI views in an instance of UICollectionView or UITableViewCell like this:

cell.contentConfiguration = UIHostingConfiguration {
    ExampleCellContentView(color: Color(item.color), text: item.text)
}
@nemorize
nemorize / korean-subway-station-list.json5
Last active March 28, 2025 04:53
대한민국 국내에 존재하는 지하철역 정보(역명, 지역구, 노선, 위/경도) 목록
[
// =======================================================
// 본 자료는 CC0-1.0 라이선스를 따릅니다.
// https://creativecommons.org/publicdomain/zero/1.0/deed
// 저작권자의 허락을 구하지 않아도 상업적인 목적을 포함한 어떠한 목적으로든
// 자유롭게 복사, 수정, 배포, 실연할 수 있습니다.
// =======================================================
// 모든 정보는 직접 수집하여 정리한 정보입니다.
// 일부 정보가 오기되었거나, 위/경도 좌표가 부정확할 수 있습니다.
// Gist 댓글을 통해 오류를 제보해주세요.
@eneko
eneko / swiftui_public_interface.swift
Created November 10, 2023 16:35
SwiftUI public interface - Xcode 15.0 15A240d
This file has been truncated, but you can view the full file.
import Accessibility
import AppKit
import Combine
import CoreData
import CoreFoundation
import CoreGraphics
import CoreText
import CoreTransferable
import Darwin
import DeveloperToolsSupport
@sebjvidal
sebjvidal / SceneDelegate.swift
Created June 27, 2023 18:14
Custom UINavigationBar Height
// MARK: - SceneDelegate
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
let navigationController = UINavigationController(navigationBarClass: NavigationBar.self, toolbarClass: nil)
(navigationController.navigationBar as! NavigationBar).preferredHeight = 88
navigationController.setViewControllers([ViewController()], animated: false)
import React
import UIKit
class SecureImageView: UIView {
@objc var url: String = "" {
didSet {
do {
let imageUrl = URL(string: url)
let data = try Data(contentsOf: imageUrl!)
let image = UIImage(data: data)
@swiftui-lab
swiftui-lab / showSizes.swift
Last active October 27, 2024 07:11
A debugging modifier for SwiftUI views (showSizes)
// Author: SwiftUI-Lab (swiftui-lab.com)
// Description: Implementation of the showSizes() debugging modifier
// blog article: https://swiftui-lab.com/layout-protocol-part-2
import SwiftUI
struct MeasureExample: View {
var body: some View {
VStack {
@ole
ole / _StackLayoutCache.swift
Last active October 19, 2024 01:53
Structure of _StackLayoutCache and related types, used by SwiftUI as the Cache type for VStackLayout and HStackLayout
// Structure of _StackLayoutCache and related types.
// Used by SwiftUI as the Cache type for VStackLayout and HStackLayout.
//
// As of: iOS 16.0 simulator in Xcode 14.0b6
import SwiftUI
struct _StackLayoutCache {
var stack: StackLayout
}
@PimCoumans
PimCoumans / TouchCancellingScrollView.swift
Created August 2, 2022 16:20
ScrollView subclass that forces touch cancellation in UIControl views
import UIKit
/// Custom scrollView that can forces touch cancellation, even in `UIControl`s
/// - Note: Make sure to set `canCancelContentTouches` to `true`
class TouchCancellingScrollView: UIScrollView {
/// Set to `false` to allow drags in`UIControls`
var canCancelControlContentTouches: Bool = true
/// Cancels all touches, even when touch is in a `UIControl`.
import SwiftUI
struct ContentView: View {
@State var path: [String] = []
func navigationButton(value: String) -> some View {
NavigationButton {
path.append(value)
} label: {
Text("NavigationButton")
@onmyway133
onmyway133 / arm64-apple-ios.swiftinterface
Created June 9, 2022 18:46
arm64-apple-ios16.swiftinterface
This file has been truncated, but you can view the full file.
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 5.7 (swiftlang-5.7.0.113.10 clang-1400.0.16.2)
// swift-module-flags: -target arm64-apple-ios16.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=checked -Osize -library-level api -library-level api -module-name SwiftUI
// swift-module-flags-ignorable: -user-module-version 4.0.66.3.102
import Accessibility
import Combine
import CoreData
import CoreFoundation
@_exported import CoreGraphics
@_exported import CoreTransferable