为什么shadow()
可以申请2次以上,每次更新,而对于.font()
即使我提出了不同的样式参数和 .font()
两次并且没有更新保持不变?
struct LabelStyle: ViewModifier { // receive view => style it up => return styled view
func body(content: Content) -> some View {
return content
.foregroundColor(Color.white)
.multilineTextAlignment(.center)
.font(Font.custom("Arial Rounded MT Bold", size: 18))
.modifier(Shadow())
.font(Font.custom("Arial Rounded MT Bold", size: 35)) // not becoming 35-sized
.modifier(differentStyledShadow()) // shadow gets updated
}
}
最佳答案
shadow() 第二次使用时不会更新之前的阴影。它创造了一个新的。
尝试更改第二个阴影的偏移量。然后你可以看到两个阴影。
您可以在运行应用程序时检查 Xcode 中的 View 检查器,以检查属性如何应用于 View 。
关于ios - viewmodifier : puzzled about how the application is different for . shadow() 和 .font 中的 Swift body 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61076136/