ptmt / react-native-macos

[deprecated in favor of https://microsoft.github.io/react-native-windows/] React Native for macOS is an experimental fork for writing desktop apps using Cocoa
MIT License
11.24k stars 429 forks source link

tintColor style property not having any effect #156

Open bbqsrc opened 7 years ago

bbqsrc commented 7 years ago

The UIExplorer test app shows the issue:

screen shot 2017-04-15 at 15 27 20

As you can see, they're all the same color when they should not be. 😉

ptmt commented 7 years ago

Yes, NSImage has no tintColor as UIImage on iOS does. So currently it's like a placeholder. Although, I can implement it by applying image transformations.

bbqsrc commented 7 years ago

Yeah, my current experimentation with that has got me to here:

extension NSImage {
    func tint(color: NSColor) {
        lockFocus()
        color.set()
        NSRectFillUsingOperation(NSMakeRect(0, 0, self.size.width, self.size.height), .sourceAtop)
        unlockFocus()
        isTemplate = false
    }
}