【问题标题】:How to make text background blur in swiftUI如何在swiftUI中使文本背景模糊
【发布时间】:2022-09-26 15:30:38
【问题描述】:

我在滚动视图中有多个引号,以文本和背景图像的形式出现,我只想为文本而不是完整图像制作视图模糊。这是代码:-

Text(text)
.padding(.trailing, 10)
.font(.custom(AppData.shared().appFont, size: 38))
.foregroundColor(.white)
.frame(width: UIScreen.screenWidth, height: UIScreen.screenHeight)
.multilineTextAlignment(.center)
.shadow(color: .black.opacity(0.5), radius: 7)
.minimumScaleFactor(0.5)
.ignoresSafeArea()

我想模糊文本背景而不是阴影。

  • 我也尝试了 .blur(radius:1) 属性,但它模糊了文本而不是文本背景..

标签: ios swift swiftui


【解决方案1】:

您可以将materialbackground 修饰符一起使用。

Text(text)
    .padding()
    .background(.ultraThinMaterial)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-10-14
    • 1970-01-01
    • 1970-01-01
    • 2017-08-05
    • 1970-01-01
    相关资源
    最近更新 更多