Skip to content

Instantly share code, notes, and snippets.

View vialyx's full-sized avatar
🎯
Focusing

Maxim Vialyx vialyx

🎯
Focusing
View GitHub Profile
private struct AssociatedKeys {
static var highlightAnimation = "VIV_highlightAnimation"
}
extension HighlightAnimatable where Self: UIView {
private var animationAvailable: Bool {
get { return (objc_getAssociatedObject(self, &AssociatedKeys.highlightAnimation) as? Bool) ?? true }
set { objc_setAssociatedObject(self, &AssociatedKeys.highlightAnimation, newValue, .OBJC_ASSOCIATION_ASSIGN) }
}
struct HighlightAnimatableSettings {
var duration: TimeInterval = 0.5
var delay: TimeInterval = 0.0
var springDamping: CGFloat = 1.0
var springVelocity: CGFloat = 0.0
var options: UIView.AnimationOptions = [.allowUserInteraction]
var transform: CGAffineTransform = .init(scaleX: 0.90, y: 0.90)
}
protocol HighlightAnimatable: class {
var settings: HighlightAnimatableSettings { get }
func lockAnimation()
func unlockAnimation()
func highlight(_ touched: Bool)
func highlight(_ touched: Bool, completion: ((Bool) -> Void)?)
}
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Setup Fetch Interval
import UIKit
final class ViewController: UIViewController {
@IBAction func photoLibraryDidTap(_ sender: Any) {
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
present(imagePickerController, animated: true, completion: nil)
}
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
// Define new Notification.Name
extension Notification.Name {
static let ButtonDidTap = Notification.Name(rawValue: "com.vialyx.ButtonDidTap")
keyboardWillHide: Optional([AnyHashable("UIKeyboardFrameBeginUserInfoKey"): NSRect: {{0, 711}, {768, 313}}, AnyHashable("UIKeyboardFrameEndUserInfoKey"): NSRect: {{0, 1024}, {768, 313}}, AnyHashable("UIKeyboardBoundsUserInfoKey"): NSRect: {{0, 0}, {768, 313}}, AnyHashable("UIKeyboardIsLocalUserInfoKey"): 1, AnyHashable("UIKeyboardCenterEndUserInfoKey"): NSPoint: {384, 1180.5}, AnyHashable("UIKeyboardCenterBeginUserInfoKey"): NSPoint: {384, 867.5}, AnyHashable("UIKeyboardAnimationCurveUserInfoKey"): 7, AnyHashable("UIKeyboardAnimationDurationUserInfoKey"): 0.25])
keyboardWillShow: Optional([AnyHashable("UIKeyboardFrameBeginUserInfoKey"): NSRect: {{0, 1024}, {768, 313}}, AnyHashable("UIKeyboardFrameEndUserInfoKey"): NSRect: {{0, 711}, {768, 313}}, AnyHashable("UIKeyboardBoundsUserInfoKey"): NSRect: {{0, 0}, {768, 313}}, AnyHashable("UIKeyboardIsLocalUserInfoKey"): 1, AnyHashable("UIKeyboardCenterEndUserInfoKey"): NSPoint: {384, 867.5}, AnyHashable("UIKeyboardCenterBeginUserInfoKey"): NSPoint: {384, 1180.5}, AnyHashable("UIKeyboardAnimationCurveUserInfoKey"): 7, AnyHashable("UIKeyboardAnimationDurationUserInfoKey"): 0.25])
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
final class MyViewController: UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white
//: A UIKit based Playground for presenting user interface
import UIKit
import PlaygroundSupport
final class MyViewController: UIViewController {
override func loadView() {
let view = UIView()
view.backgroundColor = .white