Skip to content

Instantly share code, notes, and snippets.

@matmac
Last active August 29, 2015 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matmac/da8bf7b4994e35c93908 to your computer and use it in GitHub Desktop.
Save matmac/da8bf7b4994e35c93908 to your computer and use it in GitHub Desktop.
Udemy Swift course - Code by matmac
//
// 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