Created
April 22, 2015 16:12
-
-
Save otnielgomez/5e8507829840e613e87f to your computer and use it in GitHub Desktop.
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
// | |
// 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