Skip to content

Instantly share code, notes, and snippets.

View Streebor's full-sized avatar

Stefan Vasiljevic Streebor

  • Woodstock, ON, Canada
View GitHub Profile
@insidegui
insidegui / ScrollViewOffsetModifier.swift
Created July 20, 2021 20:28
A SwiftUI ViewModifier that can be used to read a ScrollView's offset and store it into a @State property of the view
struct ScrollViewOffsetPreferenceKey: PreferenceKey {
static var defaultValue: CGPoint = .zero
static func reduce(value: inout CGPoint, nextValue: () -> CGPoint) {
value = nextValue()
print("value = \(value)")
}
typealias Value = CGPoint
@frankfka
frankfka / iOSActivityRingSwiftUI.swift
Created April 29, 2020 05:22
iOS Activity Ring in SwiftUI
import SwiftUI
import PlaygroundSupport
extension Double {
func toRadians() -> Double {
return self * Double.pi / 180
}
func toCGFloat() -> CGFloat {
return CGFloat(self)