Swiftpack.co - kkk669/RingProgressViewStyle as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by kkk669.
kkk669/RingProgressViewStyle 0.2.0
RingProgressViewStyle is a library that adds a ring style to SwiftUI's ProgressViewStyle.
⭐️ 3
🕓 31 weeks ago
iOS macOS
.package(url: "https://github.com/kkk669/RingProgressViewStyle.git", from: "0.2.0")

RingProgressViewStyle

License

RingProgressViewStyle is a library that adds a ring style to SwiftUI's ProgressViewStyle. The default apperance is based on the .linear style of ProgressViewStyle, but you can customize colors and a stroke style.

Example

Example.swiftpm can be opened in Swift Playgrounds app or Xcode.

preview

Motivation

The .circular style already exists in ProgressViewStyle, but it's just an indicator, not a progress bar. So basically, you have to implement that by yourself.

Fortunately, if you google "SwiftUI progress ring", you can find a number of code examples. Almost all of them looks like:

Circle()
    .trim(from: 0, to: value)
    .stroke(...)
    .rotationEffect(.degrees(-90))

However, when you try to specify its size by .frame(width: ..., height: ...), its stroke line overflows its frame.

To prevent this, I often use strokeBorder instead of stroke.

Circle()
    .trim(from: 0, to: value)
    .strokeBorder(...)
    .rotationEffect(.degrees(-90))

But it occurs a compilation error because trim returns some Shape that doesn't conform to InsettableShape but strokeBorder is a method of InsettableShape.

So I created a solution.

How to Use

Add this repository to your package dependencies in your app.

Supported Platforms

  • iOS 14+
  • iPadOS 14+
  • macOS 11+

GitHub

link
Stars: 3
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

0.2.0
31 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics