「SwiftUI」自定义Modifier/extension

Posted by Jiaolong on 2022/04/05

自定义Modifier

struct FullPageModifier: ViewModifier {
    func body(content:Content) -> some View {
        content
            .frame(maxWidth: .infinity, maxHeight: .infinity)
            .edgesIgnoringSafeArea(.all)
            .background(Color.systemBackground)
    }
}

自定义extension

extension Color {
    static let systemBackground = Color(UIColor.systemBackground)
}