Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save otnielgomez/5e8507829840e613e87f to your computer and use it in GitHub Desktop.
Save otnielgomez/5e8507829840e613e87f to your computer and use it in GitHub Desktop.
//
// ViewController.swift
// Ejercicio1
//
// Created by Otniel Gomez on 22/04/15.
// Copyright (c) 2015 Otniel Gomez. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
var lbl1 = UILabel()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
agregaLabel("")
var gestoTap = UITapGestureRecognizer(target: self, action: Selector("animaEnTap:"))
view.addGestureRecognizer(gestoTap)
}
func animaEnTap(tapGesture: UITapGestureRecognizer){
agregaLabel("tap")
}
func agregaLabel(seccion: String){
lbl1.text = "Ola ke ace?"
lbl1.font = UIFont.boldSystemFontOfSize(40)
lbl1.sizeToFit()
if(seccion != "tap"){
lbl1.center = CGPoint(x: -200, y: 300)
UIView.animateWithDuration(0.9, delay: 0.2, usingSpringWithDamping: 0.9, initialSpringVelocity: 0.2, options: nil, animations: {
self.lbl1.center = CGPoint(x: 260, y: 300)
}, completion: nil)
}else{
lbl1.center = CGPoint(x: 260, y: 300)
UIView.animateWithDuration(0.9, delay: 0.3, usingSpringWithDamping: 0.9, initialSpringVelocity: 0.4, options: nil, animations: {
self.lbl1.center = CGPoint(x: -200, y: 300)
}, completion: nil)
}
view.addSubview(lbl1)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment