Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.DS_Store
.build/
DerivedData/
*.xcuserstate
xcuserdata/
.swiftpm/
Package.resolved
.claude
42 changes: 42 additions & 0 deletions Example/Sources/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import SwiftUI
import Playgrounds
import TopNotch

@main struct MyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

struct ContentView: View {
@Environment(\.scenePhase) private var scenePhase
var body: some View {
Text("Hello world!")
.padding()
.onChange(of: scenePhase) {
if scenePhase == .active {
showTopNotch()
}
}
}

func showTopNotch() {
// Create a custom view (or use your own) to display behind the notch.
let notchLabel = UILabel()
notchLabel.text = "TopNotch"
notchLabel.textAlignment = .center
notchLabel.textColor = .white
notchLabel.backgroundColor = UIColor.systemBlue.withAlphaComponent(0.7)

// Show the notch view.
TopNotchManager.shared.show(customView: notchLabel, with: .init(animationDuration: 0.3,
shouldAnimate: true,
shouldHideForTaskSwitcher: false))
}
}

#Preview {
ContentView()
}
Loading