Graphics Reference
In-Depth Information
tileLayer. frame = CGRectMake ( 0 , 0 , 2048 , 2048 );
tileLayer. delegate = self ;
[ self . scrollView . layer addSublayer :tileLayer];
//configure the scroll view
self . scrollView . contentSize = tileLayer. frame . size ;
//draw layer
[tileLayer setNeedsDisplay ];
}
- ( void )drawLayer:( CATiledLayer *)layer inContext:( CGContextRef )ctx
{
//determine tile coordinate
CGRect bounds = CGContextGetClipBoundingBox (ctx);
NSInteger x = floor (bounds. origin . x / layer. tileSize . width );
NSInteger y = floor (bounds. origin . y / layer. tileSize . height );
//load tile image
NSString *imageName = [ NSString stringWithFormat :
@"Snowman_%02i_%02i , x, y];
NSString *imagePath = [[ NSBundle mainBundle ] pathForResource :imageName
ofType : @"jpg" ];
UIImage *tileImage = [ UIImage imageWithContentsOfFile :imagePath];
//draw tile
UIGraphicsPushContext (ctx);
[tileImage drawInRect :bounds];
UIGraphicsPopContext ();
}
@end
Search WWH ::




Custom Search