Graphics Reference
In-Depth Information
@end
@implementation ViewController
- ( void )viewDidLoad
{
[ super viewDidLoad ];
//create timing function
CAMediaTimingFunction *function =
[ CAMediaTimingFunction functionWithName :
kCAMediaTimingFunctionEaseOut ];
//get control points
CGPoint controlPoint1, controlPoint2;
[function getControlPointAtIndex : 1 values :( float *)&controlPoint1];
[function getControlPointAtIndex : 2 values :( float *)&controlPoint2];
//create curve
UIBezierPath *path = [[ UIBezierPath alloc ] init ];
[path moveToPoint : CGPointZero ];
[path addCurveToPoint : CGPointMake ( 1 , 1 )
controlPoint1 :controlPoint1
controlPoint2 :controlPoint2];
//scale the path up to a reasonable size for display
[path applyTransform : CGAffineTransformMakeScale ( 200 , 200 )];
//create shape layer
CAShapeLayer *shapeLayer = [ CAShapeLayer layer ];
shapeLayer. strokeColor = [ UIColor redColor ]. CGColor ;
shapeLayer. fillColor = [ UIColor clearColor ]. CGColor ;
shapeLayer. lineWidth = 4.0f ;
shapeLayer. path = path. CGPath ;
[ self . layerView . layer addSublayer :shapeLayer];
//flip geometry so that 0,0 is in the bottom-left
self . layerView . layer . geometryFlipped = YES ;
}
@end
Search WWH ::




Custom Search