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
let square = UIView(frame: CGRect(x: 10, y: 10, width: 100, height: 100)) | |
square.backgroundColor = .brown | |
self.view.addSubview(square) |
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
let square = UIView(frame: CGRect(x: 10, y: 10, width: 100, height: 100)) | |
square.backgroundColor = .brown | |
self.view.addSubview(square) |
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
let timing = UICubicTimingParameters(animationCurve: .easeOut) | |
// A global animator variable is already defined | |
animator = UIViewPropertyAnimator(duration: 2.0, timingParameters:timing) | |
animator.addAnimations { | |
square.center = CGPoint(x: 300, y: square.center.y) | |
square.transform = CGAffineTransform(rotationAngle: CGFloat.pi) | |
} | |
animator.startAnimation() |
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
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(handlePan(_:))) | |
self.view.addGestureRecognizer(panGesture) |
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
@objc func handlePan(_ gesture: UIPanGestureRecognizer) { | |
let location = gesture.location(in: self.view) | |
// To figure out the fraction completed, take the x location of the touch, | |
// and divide it by the maximum x the finger can move to (which is the screen's width) | |
let fractionCompleted = location.x / self.view.bounds.width | |
// Changing this property changes the % complete of the animation. | |
// Try experimenting with a different fraction and see what you get | |
animator.fractionComplete = fractionCompleted |
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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: deep-blue; icon-glyph: gem; | |
const widget = new ListWidget() | |
// widget.setPadding(16,16,16,16) | |
const { widgetFamily, runsInWidget } = config | |
const isSmallWidget = runsInWidget | |
? widgetFamily === 'small' | |
: false // TO SIMULATE WIDGET SIZE WHEN ON DEBUG MODE |
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
/** | |
##.......... ..........## | |
####.......... ...........#### | |
#######.......... ..........####### | |
#########.......... ...........######### | |
###########.......... ..........########### | |
##########.......... ...........########## | |
###########.......... ..........########### | |
##########........... ...........########## | |
###########.......... ..........########### |