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
// | |
// A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs. | |
// The effect is created by having hundreds of physics-enabled balls in a SpriteKit scene, | |
// all drawing nothing. These balls are then read back out by SwiftUI in a TimelineView, and | |
// drawn using blur and alpha threshold filters to make them appear to be a liquid. | |
// The SpriteKit scene then has its gravity changed dynamically using the accelerometer, | |
// meaning that the "liquid" splashes around as you tilt your phone. | |
// | |
// Created by Paul Hudson | |
// https://www.hackingwithswift.com/license |
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
extension UITextView { | |
/** | |
Calculates if new textview height (based on content) is larger than a base height | |
- parameter baseHeight: The base or minimum height | |
- returns: The new height | |
*/ | |
func newHeight(withBaseHeight baseHeight: CGFloat) -> CGFloat { |