Beispiel #1
0
function setUI() {
	var UIView = require('UIKit/UIView'),
	    UIColor = require('UIKit/UIColor'),
	    UIBezierPath = require('UIKit/UIBezierPath'),
	    CAShapeLayer = require('QuartzCore/CAShapeLayer'),
	    CGPointMake = require('CoreGraphics').CGPointMake;

	var view = UIView.cast($.container);

	var color = {
		red : 1,
		green : 1,
		blue : 1,
		alpha : 1
	};

	var path = UIBezierPath.bezierPath();
	path.moveToPoint(CGPointMake(0,0));
	path.addLineToPoint(CGPointMake(20,20));
	path.addLineToPoint(CGPointMake(0,40));

	var shapeLayer = CAShapeLayer.layer();
	shapeLayer.path = path.CGPath;
	shapeLayer.strokeColor = UIColor.colorWithRedGreenBlueAlpha(color.red, color.green, color.blue, color.alpha).CGColor;
	shapeLayer.fillColor = UIColor.clearColor().CGColor;
	shapeLayer.lineWidth = 2;
	shapeLayer.strokeStart = 0.0;
	shapeLayer.strokeEnd = 1.0;
	view.layer.addSublayer(shapeLayer);
}
	function animateSection (viewproxy, radius, startAngle, endAngle, lineWidth, duration, color) {

		var rect = view.frame;
		var centerPoint = CGPointMake(rect.size.width / 2, rect.size.height / 2);

		var path = UIBezierPath.bezierPath();
		path.addArcWithCenterRadiusStartAngleEndAngleClockwise(centerPoint, radius, DEGREES_TO_RADIANS(startAngle), DEGREES_TO_RADIANS(endAngle), true);

		var shapeLayer = CAShapeLayer.layer();
		shapeLayer.path = path.CGPath;
		shapeLayer.strokeColor = UIColor.colorWithRedGreenBlueAlpha(color.red, color.green, color.blue, color.alpha).CGColor;
		shapeLayer.fillColor = UIColor.clearColor().CGColor;
		shapeLayer.lineWidth = lineWidth;
		shapeLayer.strokeStart = 0.0;
		shapeLayer.strokeEnd = 1.0;
		view.layer.addSublayer(shapeLayer);

		var pathAnimation = CABasicAnimation.animationWithKeyPath('strokeEnd');
		pathAnimation.duration = duration;
		pathAnimation.fromValue = 0.0;
		pathAnimation.toValue = 1.0;

		shapeLayer.addAnimationForKey(pathAnimation, 'strokeEnd');
		shapes.push(shapeLayer);
	}