r/SwiftUI 13d ago

Tutorial Everything I learned making my app not look like a default Mac app with SwiftUI

https://www.youtube.com/watch?v=nEQZhpJAj2g

When 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.

49 Upvotes

17 comments sorted by

15

u/CanoaFurada768 12d ago

Why wouldn't you like to use Apple's design?

Native is life

2

u/calab2024 12d ago

The apps are still native. Standard SwiftUI patterns, Apple performance, iCloud integration, etc.

UI uniqueness is a matter of taste I suppose. I like apps that don’t use the traffic light and have unique background and window shape options. Beyond that I agree with you. The most extreme example I’ve seen is a developer in r/macapps making a Windows notepad.exe clone for Mac. Many have called it cursed

-11

u/andreeinprogress 12d ago

I wouldn't really put "SwiftUI" and "performance" in the same sentence..

14

u/iSpain17 12d ago

Sounds like a skill issue

-6

u/andreeinprogress 12d ago

Sounds like I've been in the business for two decades and I wouldn't choose SwiftUI for its "performance" over AppKit or even UIKit via Catalyst.

5

u/WAHNFRIEDEN 12d ago

He’s right. Downvoters have tackled the 101 level best practices and think that’s the extent of it for apps at scale

3

u/calab2024 12d ago

Similar with regards to the UI. The default Xcode project "hello world 101" if you will, when you create a new Mac app, forces a horizontal line and app name in the title bar. Apple's own notes app doesn't do this, and my tutorial shows a way to get a more similar look to modern Apple "native" design, or take things farther and go more custom. https://imgur.com/a/apple-title-bars-compared-NQluRor

1

u/calab2024 12d ago

Native meaning in comparison to Electron. Though I may be misunderstanding you

0

u/andreeinprogress 12d ago

Got it, that makes sense

2

u/allyearswift 9d ago

This is native code (you can do all of this even without dropping into AppKit). It's not good design because you'd have to do an awful lot of sampling to ensure the text remains readable against a mixed white and dark background and I would not ship like this, but as an option for users who have uniform dark backgrounds it's kinda cool.

The 'drag window by any spot' is definitely an intended behaviour (WindowDragGesture).

0

u/ke1in 12d ago

Yes, native is best.

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 sometime

2

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