WWDC 2006 2007 2008 2009 2010 2011 2012 2013 2014
This file contains hidden or 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
// 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 { |
This file contains hidden or 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
public extension CGPoint { | |
// The target points after decelerating to 0 velocity at a constant rate | |
func target(initialVelocity: CGPoint, decelerationRate: CGFloat = UIScrollView.DecelerationRate.normal.rawValue) -> CGPoint { | |
let x = self.x + self.x.target(initialVelocity: initialVelocity.x, decelerationRate: decelerationRate) | |
let y = self.y + self.y.target(initialVelocity: initialVelocity.y, decelerationRate: decelerationRate) | |
return CGPoint(x: x, y: y) | |
} | |
} |