📦 SwiftyLaunch Modules
🔗 SharedKit
View Modifiers
Hide sensitive views in your app

Hide Sensitive Views with the .sensitiveView() View Modifier

SharedKit Helper Function (SwiftyLaunch Module) - sensitiveView

There are often cases, where sensitive data can be displayed in your app, which your users might not want to be visible to others. Their hidden photos library would be a good example.

The .sensitiveView() view modifier allows you to hide the view's content when the app is in the background, for example in the app switcher.

View Modifier declaration:

sensitiveView.swift
extension View {
    public func sensitiveView(protectWithBiometrics: Bool = false) -> some View {
        modifier(SensitiveViewModifier(protectWithBiometrics: protectWithBiometrics))
    }
}

Simply apply it to the view you want to hide:

import SharedKit
import SwiftUI
 
struct SuperSecretView: View {
    var body: some View {
        VStack {
            Text("This is a super secret view")
        }
        .sensitiveView()
    }
}

SharedKit View Modifier Example (SwiftyLaunch Module) - sensitiveView

You might have noticed, that there is an additional parameter protectWithBiometrics in the sensitiveView() modifier.

This parameter allows you to go a step beyond and protect the view with biometric authentication, like Face ID or Touch ID, when the view is shown to the user. This way, you can ensure that only the intended user can see the content.

Read more about it in the Protecting a SwiftUI View with Face ID or Touch ID Section.