This commit is contained in:
Nadine Salter
2014-11-17 16:11:53 -08:00
parent 1fc872c06c
commit 175b872d5a
30 changed files with 2610 additions and 46 deletions

View File

@@ -211,10 +211,11 @@ class should be able to store any state your node needs to draw itself
<li><p>Return a configured instance of your draw parameters class in
<code>-drawParametersForAsyncLayer:</code>. This method will always be called on the
main thread.</p></li>
<li><p>Implement either <code>+drawRect::::</code> or <code>+displayWithParameters::</code>. Note that
these are <em>class</em> methods that will not have access to your node&#39;s state
&mdash; only the draw parameters object. They can be called on any thread
and must be thread-safe.</p></li>
<li><p>Implement either <code>+drawRect:withParameters:isCancelled:isRasterizing:</code> or
<code>+displayWithParameters:isCancelled:</code>. Note that these are <em>class</em> methods
that will not have access to your node&#39;s state &mdash; only the draw
parameters object. They can be called on any thread and must be
thread-safe.</p></li>
</ol>
<p>For example, this node will draw a rainbow:</p>
@@ -256,8 +257,9 @@ and must be thread-safe.</p></li>
</code></pre></div>
<p>This could easily be extended to support vertical rainbows too, by adding a
<code>vertical</code> property to the node, exporting it in
<code>-drawParametersForAsyncLayer:</code>, and referencing it in <code>+drawRect::::</code>.
More-complex nodes can be supported in much the same way.</p>
<code>-drawParametersForAsyncLayer:</code>, and referencing it in
<code>+drawRect:withParameters:isCancelled:isRasterizing:</code>. More-complex nodes can
be supported in much the same way.</p>
<p>For more on custom nodes, check out the <a href="https://github.com/facebook/AsyncDisplayKit/blob/master/AsyncDisplayKit/ASDisplayNode%2BSubclasses.h">subclassing
header</a>

View File

@@ -120,10 +120,12 @@ view-backed nodes also participate in asynchronous display.</p>
<p>What does this mean for your custom nodes?</p>
<p>You can implement methods like <code>-touchesBegan::</code> / <code>Moved::</code> / <code>Ended::</code> /
<code>Cancelled::</code> in your nodes exactly as you would in a UIView subclass. If you
find you need a subclass hook that hasn&#39;t already been provided, please file an
issue on GitHub &mdash; or add it yourself and submit a pull request!</p>
<p>You can implement methods like <code>-touchesBegan:withEvent:</code> /
<code>touchesMoved:withEvent:</code> / <code>touchesEnded:withEvent:</code> /
<code>touchesCancelled:withEvent:</code> in your nodes exactly as you would in a UIView
subclass. If you find you need a subclass hook that hasn&#39;t already been
provided, please file an issue on GitHub &mdash; or add it yourself and submit a
pull request!</p>
<p>If you need to interact or configure your node&#39;s underlying view or layer,
don&#39;t do so in <code>-init</code>. Instead, override <code>-didLoad</code> and check if you&#39;re