ios - viewmodifier : puzzled about how the application is different for . shadow() 和 .font 中的 Swift body 方法

标签 ios swift swift5

为什么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/

相关文章:

ios - 更新后无法使用cocoapods

ios - Facebook 邀请分享对话框无法打开 iOS Swift

swift - 为什么不在 Swift 中使用基于结构的单例

swift - 将 SwiftUI 颜色转换为 UIColor

SwiftUI 列表初始值设定项与标识(由 :)

iphone - 如何获取 nsmutablearray 中特定索引的对象

ios - iOS 应用程序的“捕获 GPU 帧”第一帧

ios - React Native Swift UI 组件框架大小

ios - 使用 CoreNFC 检测 ISO/IEC 14443(Mifare Ultralight 或 Classic)NFC 卡

ios - UIView 被带到前面后不显示