Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //: Playground - noun: a place where people can play
- import UIKit
- import XCPlayground
- let aView = UIView(frame: CGRectMake(0, 0, 200, 200))
- aView.backgroundColor = UIColor.whiteColor()
- let aLayer = CALayer()
- aLayer.bounds = CGRectMake(0, 0, 100, 100)
- aLayer.position = aView.center
- aLayer.backgroundColor = UIColor.blueColor().CGColor
- aView.layer.addSublayer(aLayer)
- aLayer.opacity = 1.0
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(0.5 * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), { () -> Void in
- // implicit
- // aLayer.transform = CATransform3DMakeRotation(CGFloat(M_PI_4), 0, 0, 1)
- // explicit
- let animation = CABasicAnimation()
- animation.keyPath = "transform"
- animation.fromValue = NSValue(CATransform3D: aLayer.transform)
- animation.toValue = NSValue(CATransform3D: CATransform3DMakeRotation(CGFloat(M_PI_4), 0, 0, 1))
- animation.duration = 1.0
- aLayer.transform = CATransform3DMakeRotation(CGFloat(M_PI_4), 0, 0, 1)
- aLayer.addAnimation(animation, forKey: "rotation")
- })
- XCPlaygroundPage.currentPage.liveView = aView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement