AsyncDisplayKit icon indicating copy to clipboard operation
AsyncDisplayKit copied to clipboard

How to custom drawing in swift?

Open smalllixin opened this issue 10 years ago • 5 comments

Anyone knows how to use swift override +drawRect:withParameters:isCancelled:isRasterizing: or +displayWithParameters:isCancelled: ?

Thanks in advaince

smalllixin avatar Jan 25 '16 07:01 smalllixin

@smalllixin you can override the drawRect as follow: override class func drawRect(bounds: CGRect, withParameters parameters: NSObjectProtocol!, isCancelled isCancelledBlock: asdisplaynode_iscancelled_block_t, isRasterizing: Bool) {}

In case you have to pass in parameters to your drawRect, because it's a class function, use the following to return an object. override func drawParametersForAsyncLayer(layer: _ASDisplayLayer) -> NSObjectProtocol? {}

1nput0utput avatar Jan 25 '16 17:01 1nput0utput

@smalllixin please reopen or ask another question if you have more issues!

appleguy avatar Jan 26 '16 03:01 appleguy

@1nput0utput Thank you very much

smalllixin avatar Jan 26 '16 04:01 smalllixin

This seems to be broken in Swift 3. "Method does not override any method from its superclass." Any idea how I can fix this?

henryeverett avatar Sep 20 '16 09:09 henryeverett

@henryeverett refer to #2299

haashem avatar Oct 01 '16 13:10 haashem