Last active
March 3, 2016 22:02
-
-
Save JohannMG/16398a9f7b8f2e7c71e8 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
//: Playground - noun: a place where people can play | |
import UIKit | |
import XCPlayground | |
var str = "Hello, playground" | |
let mainView = UIView (frame: CGRect(x: 0, y: 0, width: 300, height: 300)) | |
mainView.backgroundColor = UIColor(red: 0.74, green: 1.00, blue: 0.91, alpha: 1.00) | |
XCPlaygroundPage.currentPage.liveView = mainView | |
let tileView = UIView(frame: CGRect(x: 25, y: 100, width: 250, height: 100) ) | |
tileView.backgroundColor = UIColor.whiteColor() | |
tileView.layer.shadowColor = UIColor.blackColor().CGColor | |
tileView.layer.shadowOpacity = 0.3 | |
tileView.layer.shadowRadius = 3 | |
tileView.layer.shadowOffset = CGSize(width: 1, height: 2.2) | |
tileView.backgroundColor = UIColor(patternImage: UIImage(named: "url.jpg")!) | |
mainView.addSubview(tileView) | |
tileView.layer.anchorPoint = CGPointMake(0.0, 0.0) | |
tileView.layer.position = CGPointMake(tileView.layer.position.x - tileView.bounds.width / 2.0, tileView.layer.position.y - tileView.bounds.height / 2.0) | |
//begin upside down | |
var start = CATransform3DIdentity | |
start = CATransform3DRotate(start, CGFloat(M_PI), 1.0, 0.0, 0.0) | |
tileView.layer.transform = start | |
tileView.layer.setNeedsDisplay() | |
//let flipUp = CATransform3DMakeRotation( CGFloat(M_PI_2 * (2.0)) , 1.0, 0.0, 0.0) | |
//let flipAnimation = CABasicAnimation(keyPath: "flip") | |
var tileNew3DPos = tileView.layer.transform | |
tileNew3DPos = CATransform3DRotate(tileNew3DPos,CGFloat(-M_PI), 1.0, 0, 0) | |
UIView.animateWithDuration(1.5, animations: { () -> Void in | |
tileView.layer.transform = tileNew3DPos | |
}) { (Bool) -> Void in | |
} | |
/* | |
self.layer.position = CGPointMake(self.layer.position.x + self.bounds.size.width/2.0f, self.layer.position.y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment