fix: fully hide title bar including traffic lights
- Hide close/minimize/zoom buttons on startup - Show all buttons + title on hover, hide on exit - Use asyncAfter to ensure window is ready - Find visible window instead of first window - Enable window drag by background when title bar hidden
This commit is contained in:
parent
03b8ef8d40
commit
5a031a57ea
@ -319,10 +319,15 @@ struct PlayerContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
// 初始状态:标题栏完全隐藏
|
// 初始状态:标题栏完全隐藏(含红绿灯按钮)
|
||||||
if let win = NSApplication.shared.windows.first {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||||
|
guard let win = NSApplication.shared.windows.first(where: { $0.isVisible }) else { return }
|
||||||
win.titleVisibility = .hidden
|
win.titleVisibility = .hidden
|
||||||
win.titlebarAppearsTransparent = true
|
win.titlebarAppearsTransparent = true
|
||||||
|
win.isMovableByWindowBackground = true
|
||||||
|
win.standardWindowButton(.closeButton)?.isHidden = true
|
||||||
|
win.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
||||||
|
win.standardWindowButton(.zoomButton)?.isHidden = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onChange(of: showToolbar) { _, newValue in
|
.onChange(of: showToolbar) { _, newValue in
|
||||||
@ -333,18 +338,24 @@ struct PlayerContentView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.overlay(alignment: .top) {
|
.overlay(alignment: .top) {
|
||||||
// 标题栏悬停检测:鼠标进入显示标题,退出隐藏
|
// 标题栏悬停检测:鼠标进入显示标题栏,退出隐藏
|
||||||
Color.clear
|
Color.clear
|
||||||
.frame(height: 28)
|
.frame(height: 28)
|
||||||
.contentShape(Rectangle())
|
.contentShape(Rectangle())
|
||||||
.onHover { hovering in
|
.onHover { hovering in
|
||||||
let win = NSApplication.shared.windows.first
|
guard let win = NSApplication.shared.windows.first(where: { $0.isVisible }) else { return }
|
||||||
if hovering {
|
if hovering {
|
||||||
win?.titleVisibility = .visible
|
win.titlebarAppearsTransparent = false
|
||||||
win?.titlebarAppearsTransparent = false
|
win.titleVisibility = .visible
|
||||||
|
win.standardWindowButton(.closeButton)?.isHidden = false
|
||||||
|
win.standardWindowButton(.miniaturizeButton)?.isHidden = false
|
||||||
|
win.standardWindowButton(.zoomButton)?.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
win?.titleVisibility = .hidden
|
win.titleVisibility = .hidden
|
||||||
win?.titlebarAppearsTransparent = true
|
win.titlebarAppearsTransparent = true
|
||||||
|
win.standardWindowButton(.closeButton)?.isHidden = true
|
||||||
|
win.standardWindowButton(.miniaturizeButton)?.isHidden = true
|
||||||
|
win.standardWindowButton(.zoomButton)?.isHidden = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user