4.2.1
Show progress in your app’s Dock icon
macOS 10.15+
Add https://github.com/sindresorhus/DockProgress in the “Swift Package Manager” tab in Xcode.
https://github.com/sindresorhus/DockProgress
Latest version: 4.2.1
See the API docs.
import DockProgress foo.onUpdate = { progress in DockProgress.progress = progress }
Progress
import Foundation import DockProgress let progress = Progress(totalUnitCount: 1) progress?.becomeCurrent(withPendingUnitCount: 1) DockProgress.progressInstance = progress
The given Progress instance is weakly stored. It’s up to you to retain it.
It comes with five styles. PR welcome for more.
Check out the example app in the Xcode project.
You can also draw a custom progress with .custom(drawHandler: (_ rect: CGRect) -> Void).
.custom(drawHandler: (_ rect: CGRect) -> Void)
import DockProgress DockProgress.style = .bar
This is the default.
import DockProgress DockProgress.style = .squircle(color: .white.withAlphaComponent(0.5))
By default, it should perfectly fit a macOS 11 and later icon, but there is an inset parameter if you need to make any adjustments.
inset
import DockProgress DockProgress.style = .circle(radius: 55, color: .systemBlue)
import DockProgress DockProgress.style = .badge(color: .systemBlue, badgeValue: { getDownloadCount() })
Large badgeValue numbers will be written in kilo short notation, for example, 1012 → 1k.
badgeValue
1012
1k
Note: The badgeValue is not meant to be used as a numeric percentage. It’s for things like count of downloads, number of files being converted, etc.
import DockProgress DockProgress.style = .pie(color: .systemBlue)
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
DockProgress
Requirements
macOS 10.15+
Install
Add
https://github.com/sindresorhus/DockProgress
in the “Swift Package Manager” tab in Xcode.Latest version: 4.2.1
API
See the API docs.
Usage
Manually set the progress
Specify a
Progress
instanceThe given
Progress
instance is weakly stored. It’s up to you to retain it.Styles
It comes with five styles. PR welcome for more.
Check out the example app in the Xcode project.
You can also draw a custom progress with
.custom(drawHandler: (_ rect: CGRect) -> Void)
.Bar
This is the default.
Squircle
By default, it should perfectly fit a macOS 11 and later icon, but there is an
inset
parameter if you need to make any adjustments.Circle
Badge
Large
badgeValue
numbers will be written in kilo short notation, for example,1012
→1k
.Note: The
badgeValue
is not meant to be used as a numeric percentage. It’s for things like count of downloads, number of files being converted, etc.Pie
Related