Hi,

So, I've been experimenting with sublayers of CATiledLayer and this indeed does 
work.
I've created a CALayer which contains CAShapeLayers for all the paths. It all 
looks great, but the performance is horrible. It seems there is no bounds 
checking on the CAShapeLayers, so it tries to draw them all for each tile.
I've tried to draw the paths directly into the sublayers, but for some reason 
none of the custom drawing functions is called. Not for a CALayer subclass, nor 
if I set a delegate for the sublayer.
I create the sublayers in the following way:
-----------------------------
    CustomLayer *subLayer=[CustomLayer new];

    subLayer.bounds=bounds; //bounds is calculated somewhere above

    //let the anchorpoint correspond to (0,0) in our space
    subLayer.anchorPoint=CGPointMake(-bounds.origin.x/bounds.size.width, 
-bounds.origin.y/bounds.size.height);

    //Add a cross at (0,0), for debugging purposes
    CAShapeLayer *shape=[CAShapeLayer new];
    CGMutablePathRef path=CGPathCreateMutable();
    CGPathMoveToPoint(path, NULL, -5, 0);
    CGPathAddLineToPoint(path, NULL, 5, 0);
    CGPathMoveToPoint(path, NULL, 0, -5);
    CGPathAddLineToPoint(path, NULL, 0, 5);
    shape.path=path;
    shape.fillColor=nil;
    shape.strokeColor=[UIColor yellowColor].CGColor;

    subLayer.sublayers=subLayers; //subLayers is an array of CAShapeLayers
    [subLayer  addSublayer:shape];

    return subLayer;
-------------------------
How can I make sure that some custom drawing method get's called?

Thanks in advance.

Kind regards,

Remco Poelstra

Op 21 mrt. 2014, om 21:22 heeft Remco Poelstra <re...@beryllium.net> het 
volgende geschreven:
>>> 
>>> I'm working on an iOS app which needs to draw paths. Drawing is performed 
>>> in layers, each layer having its own color. Some paths add (opaque) 
>>> content, while some paths remove content (i.e. draw in a clear color). 
>>> Content removal should only happen on a per layer basis. This model fits 
>>> exactly with CALayer, with a CALayer for each drawing layer.
>>> The drawing layers can contain up to 30000 paths.
>>> Since I want to be able to zoom in, I'm using CATiledLayer. Unfortunately 
>>> CATiledLayer does not allow sub layers.
>> 
>> Thats news. What makes you believe this?
> 
> The internet did. But it is not true, is it? At least apple docs don't say it 
> is not possible. Then I wonder will it solve the problem of trying to draw 
> everything for each tile? Seems I've new options to try tomorrow :)
> 


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to