This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ScrollViewOffsetPreferenceKey: PreferenceKey { | |
static var defaultValue: CGPoint = .zero | |
static func reduce(value: inout CGPoint, nextValue: () -> CGPoint) { | |
value = nextValue() | |
print("value = \(value)") | |
} | |
typealias Value = CGPoint | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import PlaygroundSupport | |
extension Double { | |
func toRadians() -> Double { | |
return self * Double.pi / 180 | |
} | |
func toCGFloat() -> CGFloat { | |
return CGFloat(self) |