Graphics Reference
In-Depth Information
//create sublayer
CALayer *blueLayer = [ CALayer layer ];
blueLayer. frame = CGRectMake ( 50.0f , 50.0f , 100.0f , 100.0f );
blueLayer.backgroundColor = [UIColor blueColor ].CGColor;
//set controller as layer delegate
blueLayer.delegate = self ;
//ensure that layer backing image uses correct scale
blueLayer.contentsScale = [UIScreen mainScreen ].scale;
//add layer to our view
[ self . layerView .layer addSublayer :blueLayer];
//force layer to redraw
[blueLayer display ];
}
- ( void )drawLayer:( CALayer *)layer inContext:( CGContextRef )ctx
{
//draw a thick red circle
CGContextSetLineWidth (ctx, 10.0f );
CGContextSetStrokeColorWithColor (ctx, [ UIColor redColor ]. CGColor );
CGContextStrokeEllipseInRect (ctx, layer. bounds );
}
@end
Search WWH ::




Custom Search