Created
June 11, 2015 21:18
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
import UIKit | |
import XCPlayground | |
let view = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) | |
let shapeLayer = CAShapeLayer() | |
let size:CGFloat = 52 | |
let rect = CGRect(x: view.bounds.midX - size/2, y: view.bounds.midY-size/2, width: size, height: size) | |
shapeLayer.path = UIBezierPath(ovalInRect: rect).CGPath | |
shapeLayer.fillColor = UIColor.clearColor().CGColor | |
shapeLayer.strokeColor = UIColor.darkGrayColor().CGColor | |
shapeLayer.lineWidth = 3 | |
shapeLayer.strokeStart = 0 | |
shapeLayer.strokeEnd = 1 | |
view.layer.addSublayer(shapeLayer) | |
XCPShowView("view", view) | |
let beginTime = CACurrentMediaTime() | |
let anim1 = CABasicAnimation(keyPath: "strokeEnd") | |
anim1.fromValue = 0 | |
anim1.toValue = 1.0 | |
anim1.duration = 2.0 | |
anim1.beginTime = CACurrentMediaTime() | |
let anim2 = CABasicAnimation(keyPath:"strokeStart") | |
anim2.fromValue = 0 | |
anim2.toValue = 0.1 | |
anim2.duration = 2.0 | |
anim2.beginTime = CACurrentMediaTime() + 2.0 | |
let group = CAAnimationGroup() | |
group.animations = [anim1, anim2] | |
group.duration = 4.0 | |
//shapeLayer.addAnimation(anim1, forKey:nil) | |
//shapeLayer.addAnimation(anim2, forKey:nil) | |
shapeLayer.addAnimation(group, forKey: nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment