swift - 如何在 macOS 上使用 SwiftUI 2 禁用全屏按钮
解决方案
您可以简单地使用.onReceive
修饰符来达到目的:
struct MacApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.frame(width: 480, height: 272)
.fixedSize()
.onReceive(NotificationCenter.default.publisher(for: NSApplication.willUpdateNotification), perform: { _ in
for window in NSApplication.shared.windows {
window.standardWindowButton(.zoomButton)?.isEnabled = false
}
})
}
.windowStyle(HiddenTitleBarWindowStyle())
}
推荐阅读
- c - 整数错误代码和 OpenSSL 错误常量之间的映射
- mysql - SQL 语句 - 将行值更新为最大值
- python - 单次上传,写入csv并返回图片文件Flask
- python - nbconvert 没有选择默认的 jupyter 主题
- python-3.x - 如何在 github 操作工作流结果状态中排除退出代码?
- arrays - 我可以传入什么作为映射函数中第一个参数的占位符警告:遇到两个具有相同键的孩子,`[object Object]`
- javascript - 如何填充分段的 D3 弧
- python-3.x - 而循环计数器正在返回 NoneType
- android - 如何在 API 29 或更高版本上更改文本状态栏颜色
- postgresql - 使用 psycopg2 调用 postgres 存储过程 - 无效的事务终止