Skip to content

Latest commit

 

History

History
47 lines (38 loc) · 2.07 KB

File metadata and controls

47 lines (38 loc) · 2.07 KB

macOS Title Bar Suppression - SOLVED ✅

Problem Summary

A macOS SwiftUI app called "Writer" that has a hidden title bar mode. The app needed to eliminate all visual artifacts when the title bar is hidden, including a persistent gray line separator.

Final Status

  • ✅ White title bar area is properly suppressed
  • ✅ Gray line separator completely eliminated
  • ✅ Perfect hidden title bar mode achieved
  • ✅ Clean, maintainable implementation

The Solution

The key breakthrough was using window.titlebarSeparatorStyle = .none (macOS 12+)

This property directly controls the title bar separator line that appears between the title bar and content area - exactly what was causing the gray line issue.

Final Implementation Features

  1. Perfect hidden title bar mode - no visual artifacts at all
  2. Hover-to-reveal functionality - 50px band at top reveals title bar on hover
  3. ⌘T hotkey toggle - switches between hidden/visible title bar modes
  4. Clean code - removed all aggressive/nuclear approaches after finding the proper solution

Technical Context

  • App: macOS SwiftUI app with NSWindow manipulation
  • Architecture: Uses WindowController.swift with NSWindowDelegate + ContentView.swift
  • Final Implementation: Clean approach using proper NSWindow properties
  • Target: macOS 14 (Sonoma) compatibility, with macOS 12+ for separator control

Core Implementation

// The key fix: Disable title bar separator (macOS 12+)
if #available(macOS 12.0, *) {
    window.titlebarSeparatorStyle = titleBarHidden ? .none : .automatic
}

Files Involved

  • /Users/andreas/Coding/Writer/Writer/WindowController.swift - Clean title bar suppression logic
  • /Users/andreas/Coding/Writer/Writer/ContentView.swift - UI and event handling

Cleaned Up Approach

The final implementation uses:

  • Targeted title bar view suppression (not aggressive)
  • Proper NSWindow configuration with fullSizeContentView
  • titlebarSeparatorStyle = .none for gray line elimination
  • Comprehensive logging for debugging
  • Clean, maintainable code without nuclear approaches