Dock Badge Dock 角标 macos

3

标本可交互 —— 点点看。Specimen is live — try it.

Anatomy — every part, named解剖 —— 每个部件的名字

  1. 1 Badge label角标标签 NSDockTile.badgeLabel

    “The red number bubble on the app icon” is the Dock tile's badge label.

    「应用图标上的红色数字气泡」就是 Dock tile 的角标标签。

    Prompt fragmentPrompt 片段

    the NSDockTile.badgeLabel as a compact red count badge over the Dock icon's upper-right corner

    NSDockTile.badgeLabel:叠在 Dock 图标右上角的紧凑红色数字角标

  2. 2 Attention bounce提醒弹跳 NSApplication.requestUserAttention(_:)

    “The app icon jumping in the Dock” is an attention bounce, not part of the badge.

    「应用图标在 Dock 里跳」是提醒弹跳,不属于角标。

    Prompt fragmentPrompt 片段

    an NSApplication.requestUserAttention(_:) Dock-icon bounce used separately from NSDockTile.badgeLabel

    用 NSApplication.requestUserAttention(_:) 触发的 Dock 图标弹跳,与 NSDockTile.badgeLabel 分开使用

Prompt — paste into your agentPrompt —— 直接粘贴给你的代理

Show a Dock Badge by assigning the count to NSApp.dockTile.badgeLabel, clearing the label when no count remains. If stronger attention is warranted, call NSApplication.requestUserAttention(_:) separately to bounce the Dock icon; the bounce is not the badge itself.

把数量赋给 NSApp.dockTile.badgeLabel 来显示 Dock 角标,数量清零时清空 label。如果需要更强的提醒,单独调用 NSApplication.requestUserAttention(_:) 让 Dock 图标弹跳;弹跳不是角标本体。

Debug prompt — when it misbehaves调试 Prompt —— 当它不听话时

Debug my macOS Dock badge (NSDockTile.badgeLabel, NSApp.dockTile). Rule out: clearing with the string zero instead of nil or empty so a 0 stays visible; setting the badge from a background thread; expecting the badge to survive quit — it lives only while the app runs (UNUserNotificationCenter badge APIs persist); long strings truncating in the tile. The symptom:

调试我的 macOS Dock 角标(NSDockTile.badgeLabel、NSApp.dockTile)。排除以下可能:用字符串「0」而不是 nil 或空串来清除,导致 0 一直显示;在后台线程设置角标;指望角标在退出后保留——它只在应用运行期间存在(UNUserNotificationCenter 的 badge API 才能持久);长字符串在图标上被截断。症状是:

In code代码里叫什么

Framework框架Symbol符号Note说明
AppKit NSDockTile.badgeLabel
AppKit NSApplication.dockTile
AppKit NSApplication.requestUserAttention(_:) bounces the Dock icon; separate from the badge让 Dock 图标弹跳;和角标是两回事
AppKit NSApplication.RequestUserAttentionType

See also相关词条