mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-04-24 03:45:58 +08:00
Regen on 3c8d4e9517.
This commit is contained in:
@@ -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's state
|
||||
— 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's state — 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>
|
||||
|
||||
@@ -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't already been provided, please file an
|
||||
issue on GitHub — 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't already been
|
||||
provided, please file an issue on GitHub — or add it yourself and submit a
|
||||
pull request!</p>
|
||||
|
||||
<p>If you need to interact or configure your node's underlying view or layer,
|
||||
don't do so in <code>-init</code>. Instead, override <code>-didLoad</code> and check if you're
|
||||
|
||||
Reference in New Issue
Block a user