• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Simulating sublayers in CATiledLayer
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Simulating sublayers in CATiledLayer


  • Subject: Re: Simulating sublayers in CATiledLayer
  • From: Remco Poelstra <email@hidden>
  • Date: Sat, 22 Mar 2014 10:18:37 +0100

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 <email@hidden> 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 (email@hidden)

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:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Simulating sublayers in CATiledLayer
      • From: David Duncan <email@hidden>
References: 
 >Simulating sublayers in CATiledLayer (From: Remco Poelstra <email@hidden>)
 >Re: Simulating sublayers in CATiledLayer (From: David Duncan <email@hidden>)
 >Re: Simulating sublayers in CATiledLayer (From: Remco Poelstra <email@hidden>)

  • Prev by Date: Re: Simulating sublayers in CATiledLayer
  • Next by Date: Problems binding NSViewController's representedObject
  • Previous by thread: Re: Simulating sublayers in CATiledLayer
  • Next by thread: Re: Simulating sublayers in CATiledLayer
  • Index(es):
    • Date
    • Thread