Hi StackOverflowers
I am working on an iphone application that displays tiled maps. I am currently using a CATiledLayer in a UIScrollView :
MyTiledDelegate *delegate=[[MyTiledDelegate alloc] initWithMapLayer:map];
tileLayer = [CATiledLayer layer];
tileLayer.delegate = delegate;
[scrollView.layer addSublayer:tileLayer];
[tileLayer setNeedsDisplay];
I wrote and set my own delegate which implements the draw layer method like so :
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
CGRect rect =CGContextGetClipBoundingBox(ctx);
CGFloat x = fabs(round(rect.origin.x/tileSize));
CGFloat y = fabs(round(rect.origin.y/tileSize));
Tile *tile = [map getTileForMapZoom:z x:x y:y];
CGImageRef img=[tile getRealImage];
CGContextDrawImage(
ctx,
CGRectMake(tile.x*tileSize,tile.y*tileSize, tileSize,tileSize) ,
img);
}//edited for brevity
I am annoyed by the default behavior of the CAtiledLayer to fadein after the tile is drawn. Also, sometimes the fadein is not complete (it stops at 90 or 95% opacity).
How can i change or (preferably) remove the fadein animation ?
I played with the speed
and duration
properties of my CATiledLayer instance, to no avail. I don't set any animation on the tiledLayer. the [tiledLayer removeAllAnimation]
does not change anything either.
Thanks for any pointers.