Last active
August 29, 2015 14:10
-
-
Save matmac/da8bf7b4994e35c93908 to your computer and use it in GitHub Desktop.
Udemy Swift course - Code by matmac
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 | |
// ParquoIos | |
// | |
// Created by matmac on 23/11/14. | |
// Copyright (c) 2014 Infinite Spot S.L. All rights reserved. | |
// | |
import UIKit | |
class ViewController: UIViewController { | |
// Create instance variables | |
var tinyLabel: UILabel! | |
var largeLabel: UILabel! | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// Do any additional setup after loading the view, typically from a nib. | |
// Create labels | |
tinyLabel = UILabel() | |
largeLabel = UILabel() | |
addLabels() | |
var tapGesture = UITapGestureRecognizer(target: self, action: Selector("handleTapGesture:")) | |
view.addGestureRecognizer(tapGesture) | |
} | |
func handleTapGesture(tapGesture: UITapGestureRecognizer) { | |
println("tap") | |
addLabels() | |
} | |
func addLabels() { | |
tinyLabel.text = "My First" | |
tinyLabel.font = UIFont.systemFontOfSize(36) | |
tinyLabel.sizeToFit() | |
tinyLabel.center = CGPoint(x: 100, y: 40) | |
view.addSubview(tinyLabel) | |
tinyLabel.alpha = 0 | |
UIView.animateWithDuration(0.5, delay: 0.0, usingSpringWithDamping: 0.9, initialSpringVelocity: 0.0, options: nil, animations: { | |
self.tinyLabel.center = CGPoint(x: 100, y: 40+200) | |
self.tinyLabel.alpha = 1 | |
}, completion: nil) | |
largeLabel.text = "iPhone App" | |
largeLabel.font = UIFont.boldSystemFontOfSize(48) | |
largeLabel.sizeToFit() | |
largeLabel.center = CGPoint(x: -250, y: 280) | |
view.addSubview(largeLabel) | |
largeLabel.alpha = 0 | |
UIView.animateWithDuration(2.5, delay: 0.5, usingSpringWithDamping: 0.5, initialSpringVelocity: 0.0, options: nil, animations: { | |
self.largeLabel.center = CGPoint(x: 200, y: 280) | |
self.largeLabel.alpha = 1 | |
}, completion: nil) | |
} | |
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