Skip to content

Instantly share code, notes, and snippets.

View bryan1anderson's full-sized avatar

Bryan Anderson bryan1anderson

View GitHub Profile
@bryan1anderson
bryan1anderson / BrokenScrollPosition.swift
Created August 8, 2025 18:11
SwiftUI ScrollView ScrollPosition Anchor is broken
import SwiftUI
/**
This view demonstrates that scroll anchors are IGNORED when using `.scrollPosition(...).scrollTo(id:anchor:)`.
- Using `.scrollViewProxy.scrollTo(id:anchor:)` works correctly, anchors are respected.
- Using `.scrollPosition.scrollTo(id:anchor:)` ignores the anchor, always positions the target at the same place.
Use this as a proof-of-bug or platform inconsistency.
*/
struct ContentView: View {
@bryan1anderson
bryan1anderson / SwiftUI+Frame.swift
Created January 2, 2025 15:54
SwiftUI frame(infinity: .width)
public enum FrameDimension {
case width, height
}
extension View {
public func frame(infinity dimensions: FrameDimension...) -> some View {
var maxWidth: CGFloat?
var maxHeight: CGFloat?
for dimension in dimensions {
@bryan1anderson
bryan1anderson / Live Photo Compressible
Last active August 23, 2016 02:38
Credit goes to Genady Okrain for his work on creating Live Photos from video assets. I was able to use a lot of his code to make sure all of the PHLivePhoto meta-data was working properly: https://github.com/genadyo/LivePhotoDemo
//
// LivePhotoCompressible.swift
// Swop
//
// Created by Bryan on 5/18/16.
// Copyright © 2016 Swop. All rights reserved.
//
import Foundation
import UIKit