Skip to content

Instantly share code, notes, and snippets.

View victorBaro's full-sized avatar
👾

Victor Baro victorBaro

👾
View GitHub Profile
@victorBaro
victorBaro / ForceGestureRecognizer.swift
Last active May 5, 2018 21:29
Custom GestureRecognizer for Force Touch
import UIKit.UIGestureRecognizerSubclass
class ForceGestureRecognizer: UIGestureRecognizer {
var forceValue: CGFloat = 0
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
state = .Began
handleForceWithTouches(touches)
@IBAction func viewDragged(sender: UIPanGestureRecognizer) {
let yTranslation = sender.translationInView(view).y
if (hasExceededVerticalLimit(topViewConstraint.constant)){
totalTranslation += yTranslation
topViewConstraint.constant = logConstraintValueForYPoisition(totalTranslation)
if(sender.state == UIGestureRecognizerState.Ended ){
animateViewBackToLimit()
}
} else {
topViewConstraint.constant += yTranslation
@victorBaro
victorBaro / AnimatedLabel
Created March 22, 2015 22:44
Swift test from original Nick Lockwood article: https://gist.github.com/nicklockwood/d374033b27c62662ac8d (animated UILabel on text changes)
import UIKit
class ViewController: UIViewController {
let magicLabel = AnimatedLabel(frame: CGRectMake(100, 100, 300, 20));
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
magicLabel.text = "Magic label"
self.view.addSubview(magicLabel);
@victorBaro
victorBaro / CustomDynamicAlertView
Created February 23, 2015 09:52
Small class (Alert View) we made during third week at ironhack bootcamp using UIKit Dynamics. http://victorbaro.com/2015/02/custom-dynamic-alertview/
//
// CustomDynamicAlertView.h
// Week3_inclass
//
// Created by Victor Baro on 18/02/2015.
// Copyright (c) 2015 Produkt. All rights reserved.
//
#import <UIKit/UIKit.h>