Open Pranoy1c opened 1 month ago
Currently, no. As a workaround overlay Color.black.opacity(...) to Color.clear gradient.
In fact I disable darkening and saturation layers of UIVisualEffectView because it creates a visible line at clear end of the view:
Ideally, we wouldn't do this and instead apply opacity gradient.
Also change style used to explicitly dark material:
Any PRs that tackle this will be absolutely welcome!
I was able to create darkened gradient blur using the solution by @Sweeper here:
https://stackoverflow.com/a/78877606/1634905
In the VariableBlurUIView
, add:
let darkLayer = CALayer()
Then, in the init
, add:
darkLayer.contents = gradientImage
darkLayer.zPosition = -1
backdropLayer?.superLayer?.addSublayer(darkLayer)
Add the following functions:
open override func layoutSublayers(of layer: CALayer) {
darkLayer.frame = subviews.first?.layer.frame ?? .zero
}
And change the color0
in makeGradientImage
func to black with alpha which you think is appropriate:
CIColor(color: UIColor.black.withAlphaComponent(0.7))
Result:
Oh, you use makeGradientImage
. Nice. Note that variableBlur
uses opacity to determine blur radius so if you reuse the same clear to 0.7 black gradient, variable blur will only go from 0 to 0.7*maxBlurRadius
.
Is there a way to create a darker blur? Dark enough so that the status bar always shows white text instead of black? How can I control?