Search code examples
swiftmacosnsimage

Drawing Transparent image over NSImage


I'm trying to draw a logo in an image.This works fine using the following code

logo!.draw(in:logoRect)

But there is no transparency option,so i use another parameter.But this does not produce any output.

logo?.draw(in: mainimage, from: logoRect, operation: NSCompositingOperation.sourceOver, fraction: 0.5)

Solution

  • logo!.draw(in:logoRect)

    if above works then use the following

    logo!.draw(in:logoRect, from: .zero, operation: .sourceOver, fraction: 0.5))