Open auramagi opened 2 years ago
iOS 16 / macOS Ventura brings the new ImageRenderer class 🎉
Need to test whether it solves these problems.
ImageRenderer
does seem to eliminate blend mode problems, but so does cacheDisplay
in Ventura 🤔
cacheDisplay | ImageRenderer |
---|---|
![]() |
![]() |
ImageRenderer output seems to be blurry, but maybe I'm just holding it wrong. Will revisit later, for now experimental support is in feature/ImageRenderer branch.
These are current view capture steps:
cacheDisplay(in:to:)
However, using
cacheDisplay
produces some side-effects and the resulting image does not exactly match View as displayed.To get around some display issues, we tell SwiftUI to first flatten view hierarchy by itself using the drawingGroup modifier.
But even this has some weirdness, especially with blend modes. First of all, it loses all transparency, but that part is at least consistent with previews/actual rendering after using
drawingGroup
.Using
.overlay(Color.mint.blendMode(.hue))
:We can get around that by masking the result with the initial view: https://github.com/auramagi/NewIcon/blob/f441f60ac09beb74ec46719aff0ef1277e8ae6ef/SampleTemplates/NewHue.swift#L53
But this still leaves us with incorrectly blended color in some parts.
Compare to how this looks in previews and when displayed in a window.