added a callback for initWithViewBlock/initWithLayerBlock

This commit is contained in:
rcancro
2015-09-14 20:36:08 -07:00
parent 6ce077be5a
commit 01be5acece
7 changed files with 85 additions and 27 deletions

View File

@@ -19,10 +19,19 @@
* UIView creation block. Used to create the backing view of a new display node.
*/
typedef UIView *(^ASDisplayNodeViewBlock)();
/**
* UIView loaded callback block. Used for any additional setup to the view created by viewBlock.
*/
typedef void (^ASDisplayNodeViewLoadedBlock)(UIView *loadedView);
/**
* CALayer creation block. Used to create the backing layer of a new display node.
*/
typedef CALayer *(^ASDisplayNodeLayerBlock)();
/**
* CALayer loaded callback block. Used for any additional setup to the layer created by layerBlock.
*/
typedef void (^ASDisplayNodeLayerLoadedBlock)(CALayer *layer);
/**
* An `ASDisplayNode` is an abstraction over `UIView` and `CALayer` that allows you to perform calculations about a view
@@ -65,6 +74,17 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
*/
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock;
/**
* @abstract Alternative initializer with a block to create the backing view.
*
* @param viewBlock The block that will be used to create the backing view.
* @param viewLoadedBlock The block that will be called after the view created by the viewBlock is loaded
*
* @return An ASDisplayNode instance that loads its view with the given block that is guaranteed to run on the main
* queue. The view will render synchronously and -layout and touch handling methods on the node will not be called.
*/
- (id)initWithViewBlock:(ASDisplayNodeViewBlock)viewBlock viewDidLoadBlock:(ASDisplayNodeViewLoadedBlock)viewLoadedBlock;
/**
* @abstract Alternative initializer with a block to create the backing layer.
*
@@ -73,7 +93,18 @@ typedef CALayer *(^ASDisplayNodeLayerBlock)();
* @return An ASDisplayNode instance that loads its layer with the given block that is guaranteed to run on the main
* queue. The layer will render synchronously and -layout and touch handling methods on the node will not be called.
*/
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)viewBlock;
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock;
/**
* @abstract Alternative initializer with a block to create the backing layer.
*
* @param viewBlock The block that will be used to create the backing layer.
* @param layerLoadedBlock The block that will be called after the layer created by the layerBlock is loaded
*
* @return An ASDisplayNode instance that loads its layer with the given block that is guaranteed to run on the main
* queue. The layer will render synchronously and -layout and touch handling methods on the node will not be called.
*/
- (id)initWithLayerBlock:(ASDisplayNodeLayerBlock)layerBlock layerDidLoadBlock:(ASDisplayNodeLayerLoadedBlock)layerLoadedBlock;
/** @name Properties */