0

I am having some troubles to integrate a background view with a blurred linear gradient on iOS15, the same code doesn't have the same result as iOS16 (What is the behavior I am expecting to have on all my iOS targets)

Here is a sample code to reproduce nearly the same view, just different colors because the ones in the picture are from my internal constants

import SwiftUI

struct HighlightComponentView: View {
    let title: LocalizedStringKey
    var style: Font = .largeTitle

    var body: some View {
        Text(title)
            .font(style)
            .foregroundColor(.white)
            .padding(3)
            .background(
                LinearGradient(
                    gradient: .init(colors: [.blue.opacity(0.6), .red]),
                    startPoint: .init(x: 0.63, y: 0.98),
                    endPoint: .init(x: 0.58, y: 0.02))
                .clipShape(Capsule())
                .blur(radius: 8, opaque: false))
    }
}

struct StancerHighlightComponentView_Previews: PreviewProvider {
    static var previews: some View {
        HighlightComponentView(title: "Connexion")
    }
}
iOS16 iOS15
iOS16 iOS15

Does anyone can help me to achieve the same result as I have on iOS 16 for both iOS versions ?


After some tests I have realized that this difference of result can be seen on any kind of gradient, when on color it does not happen, however I still didn't find any solution.

I also would like to say that moving up to iOS16 minimum target or removing the blur are not options that I can consider.

SnK
  • 58
  • 1
  • 6
  • The second one is not blurred. So drop the blur and they should be the same. – matt Jan 13 '23 at 19:25
  • I want to achieve the result with the blur on both iOS.. The blur has to be only on the background not the text – SnK Jan 13 '23 at 20:41

0 Answers0