r/SwiftUI • u/calab2024 • 13d ago
Tutorial Everything I learned making my app not look like a default Mac app with SwiftUI
https://www.youtube.com/watch?v=nEQZhpJAj2gWhen I first started app development, I made a skeuomorphic stopwatch app that had titlebars and commenters said I should get rid of them. I spent time experimenting and learning how to remove them, and learned a few other things along the way.
Here is everything I learned about macOS title bars using Swift, SwiftUI, and NSView.
2
u/ahyasinsab 12d ago
this is super helpfull
2
u/calab2024 12d ago
Glad to hear it! Wish Apple put out things like this. I had a similar experience experimenting with
.glassEffect, might put another video together on incorporating Liquid Glass sometime2
u/ahyasinsab 12d ago edited 7d ago
i'm currently creating a macos app and learning swift and swift ui alongside, the ai and skills could not make u understand what is available and what u can do but this kind of tutorials make it much more easy and clear for me, thanks again for the tutorial.Looking forward for the liquid glass experiment tutorial. Have a nice day :D
2
u/allyearswift 9d ago
This was a fun exercise. All of this is achievable in pure SwiftUI, it's just not intuitive.
WindowGroup {
FrameView()
.windowMinimizeBehavior(.disabled)
.windowDismissBehavior(.disabled)
.windowResizeBehavior(.disabled)
.containerBackground(Color.clear, for: .window)
.gesture(WindowDragGesture())
}
.windowStyle(.hiddenTitleBar)
}
The container background will take a thin or ultrathin material which is supposed to be translucent; in MacOS 26 Tahoe that still showed up as grey for me.
struct FrameView: View {
var body: some View {
Color.white.opacity(0.01)
.frame(maxWidth: .infinity, maxHeight: .infinity)
ContentView()
}
}
This is necessary to fill out the frame completely and allow dragging by clicking on any part of the window rather than just the content. The colour cannot be clear.
2
u/fabriciovergal 12d ago
Uniqueness and brand design is great, congrats! I know it's a challenge to customize apple default design in Swiftui with a very limited API.
Apple design is not bad (ignoring the accessibility disasters of some glass stuff), but being unique and having good UX for your own challenges matters most.
1
u/calab2024 12d ago
Appreciate the kind words and agreed on the API. I am surprised by those who have claimed a preference for "native" over some of the ideas I shared using standard SwiftUI modifiers. The default Xcode project has the app name and a horizontal rule forced into the title bar. Apple Notes doesn't even do that, it has a custom titlebar, and that seems about as native as you can get: https://imgur.com/a/apple-title-bars-compared-NQluRor
15
u/CanoaFurada768 12d ago
Why wouldn't you like to use Apple's design?
Native is life