Asyncdisplaykit: [ASImageNode] Consider automatically applying .tintColor property without setting .imageModificationBlock

Created on 15 Apr 2015  路  15Comments  路  Source: facebookarchive/AsyncDisplayKit

Here's the code:

    searchIcon = ASImageNode()
    searchIcon.image = UIImage(named: "IconSearch")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate)
    searchIcon.tintColor = UIColor.redColor()

No matter what color I put in tintColor, it's always tinted pure black. Am I using this improperly or is this attribute not supported?

Bug

Most helpful comment

@markmark1 something like this maybe:
imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.whiteColor())

All 15 comments

We did add support for tintColor, but it is possible that there is a bug. Perhaps more likely, it may not be supported by ASImageNode to do the tinting automatically. I'm pretty sure, however, that tint color notifications and property updates do propagate correctly. The main intended usage of it is for custom classes that want to tap into tintColor.

In the meantime, are there any workarounds to allow us to use ASImageNode with a tinted template image?

I'm facing the same issue, seems tintColor has no effect on ASImageNode.

@SilverEnderman @yxztj just use ASImageNode's imageModificationBlock property. There is even ready to use ASImageNodeTintColorModificationBlock.

It works! awesome!

Thanks @Jercik for the help.

Is there an example to use聽imageModificationBlock

On Fri, Jul 10, 2015 at 7:47 AM, 艁ukasz Jerci艅ski
[email protected] wrote:

@SilverEnderman @yxztj just use ASImageNode's imageModificationBlock property. There is even ready to use ASImageNodeTintColorModificationBlock.

Reply to this email directly or view it on GitHub:
https://github.com/facebook/AsyncDisplayKit/issues/426#issuecomment-120426822

@Jercik I am seeing the same issue is affecting the tintColor on the ASTextNode is there a workaround for this? (it's in the context of this #571)

@RuiAAPeres hey there 鈥斅爐hanks for reporting the issue. To be honest, I'm not very familiar with how tintColor behaves with some of these UIKit classes, as it does not appear to be very well documented. E.g., is it supposed to change link colors? But not any other color in the text?

I'd welcome any diffs changing the behavior, as it should be pretty easy to do by looking at the internals of ASTextNode. Or, if you can describe the expected behavior or provide a test project comparing to UIKit, it will allow one of the many other developers on the project to implement it :).

@appleguy hey there! The tintColor issue is described in #571.

@markmark1 something like this maybe:
imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.whiteColor())

my solution use ASDisplayNode init(viewBlock: ASDisplayNodeViewBlock)

let node = ASDisplayNode(viewBlock: { () -> UIView in

                let imageView = UIImageView(image:   image?.imageWithRenderingMode(.AlwaysTemplate))
                imageView.alpha = alpha
                imageView.tintColor = color
                return imageView
            })
node.preferredFrameSize = image?.size ?? .zero

This issue was moved to TextureGroup/Texture#99

@markmark1 something like this maybe:
imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.whiteColor())

@RuiAAPeres @markmark1
Possible to change it dynamically from say .white to .black later?
Setting it again makes no difference to the imagenode right now.

@markmark1 something like this maybe:
imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.whiteColor())

@RuiAAPeres @markmark1
Possible to change it dynamically from say .white to .black later?
Setting it again makes no difference to the imagenode right now.

Ever figured this out?

@markmark1 something like this maybe:
imageNode.imageModificationBlock = ASImageNodeTintColorModificationBlock(.whiteColor())

@RuiAAPeres @markmark1
Possible to change it dynamically from say .white to .black later?
Setting it again makes no difference to the imagenode right now.

Ever figured this out?

Hey @RuiAAPeres @ndemie

someImage.imageModificationBlock = ASImageNodeTintColorModificationBlock(someUIColor) someImage.setNeedsDisplay()

Remember to ask to re-render the image, only then will it show the new color.
Been working for fine for me after the setNeedsDisplay().

Was this page helpful?
0 / 5 - 0 ratings