Skip to content

Instantly share code, notes, and snippets.

@harlanhaskins
harlanhaskins / View+ParentViewController.swift
Last active March 26, 2025 12:01
A SwiftUI modifier for inserting the parent UIViewController in the environment
import Foundation
import SwiftUI
extension View {
/// Adds introspection to find the parent view controller in the view hierarchy and
/// makes that view controller available to downstream views in the view hierarchy.
public func addParentViewControllerIntrospection() -> some View {
modifier(ParentViewControllerEnvironmentModifier())
}
}
@j-j-m
j-j-m / commonprofile.metal
Created May 8, 2017 00:20
Can't access GL Uniforms in Metal shader modifier? Apple docs for SCNShadable written in terms of GL? Pulling your hair out?... this will help.
////////////////////////////////////////////////
// CommonProfile Shader v2
#import <metal_stdlib>
using namespace metal;
#ifndef __SCNMetalDefines__
#define __SCNMetalDefines__
@eoghain
eoghain / CustomInteractiveAnimationNavigationController.swift
Last active August 11, 2024 09:49
UINavigationController that implements swipe to push/pop in an interactive animation. Just implement the InteractiveNavigation protocol on your ViewControllers you add to the nav stack to get custom transitions. Or implement a single animation and return it instead of the nil's in the UIViewControllerTransitioningDelegate and all transitions wil…
import UIKit
protocol InteractiveNavigation {
var presentAnimation: UIViewControllerAnimatedTransitioning? { get }
var dismissAnimation: UIViewControllerAnimatedTransitioning? { get }
func showNext()
}
enum SwipeDirection: CGFloat, CustomStringConvertible {
@tkersey
tkersey / .2025.md
Last active April 24, 2025 20:41
For future reference but maybe not.

Quick access

2025

April

  • Create an extra layer of security for your private keys.

    Keeping a private key in a keychain is a great way to secure it. The key data is encrypted on disk and accessible only to your app or the apps you authorize. However, to use the key, you must briefly copy a plain-text version of it into system memory. While this presents a reasonably small attack surface, there’s still the chance that if your app is compromised, the key could also become compromised. As an added layer of protection, you can protect a private key using the Secure Enclave. >

@zacwest
zacwest / ios-font-sizes.swift
Last active April 24, 2025 07:18
iOS default font sizes - also available on https://www.iosfontsizes.com
let styles: [UIFont.TextStyle] = [
// iOS 17
.extraLargeTitle, .extraLargeTitle2,
// iOS 11
.largeTitle,
// iOS 9
.title1, .title2, .title3, .callout,
// iOS 7
.headline, .subheadline, .body, .footnote, .caption1, .caption2,
]