• Stars
    star
    175
  • Rank 218,059 (Top 5 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This project has been deprecated.

Circular Progress View

A customisable Swift class for a progress view similar to what the Apple Watch has.

IMPORTANT

2016.12.03: This project has been deprecated for the time being as it uses Swift 1.2 and I don't intend to update it any time soon. It's still useful as a learning resource but that's about it for now.

Motivation

You may have seen that the Apple Watch has some cool new progress views, like this:

Image from Apple Watch Human Interface Guidelines

I wanted to create something similar and this project is the result of that effort.

API

You use a CircularProgressView much like you'd use a regular UIProgressView. You instantiate a CircularProgressView either directly on Interface Builder or programmatically. The class supports IB rendering so when you instantiate it directly on IB, you can manipulate its parameters from an inspector, with immediate feedback.

You can customize:

  • the track tint: The color of the full track.
  • the progress tint: The color of the portion of the track that represents the progress made.
  • the track thickness: The thickness (in points) of the full track.
  • the progress thickness: The thickness (in points) of the portion of the track that represents the progress made. There's also another way to set or change the progress thickness but you can only do it programmatically. See the source file for details.
  • the direction of rotation: Whether the progress track grows clockwise or counterclockwise.
  • the mode of progress: Whether the view displays the progress itself (regular mode) or what's left of it (reversed mode).
  • whether or not to display a label showing the percentage of completion (regular mode) or the percentage of what's left to complete (reversed mode). The label is optional, automatically created if necessary, and you can customise it in many ways. Also, it automatically makes sure that the text is not going to be too large.
  • the percentage tint: The color of the percentage text shown by the label.
  • the percentage font size: The font size of the percentage text shown by the label.
  • whether or not to display the percentage text using the bold system font (as opposed to the regular system font). Note that although you can't change the actual font of the label through IB, you can do so programmatically by accessing the label and costumising it to your liking.
  • the progress value displayed by the progress view. This is what you'd play with in IB to see how your other customisation choices feel like. In IB, the values you enter in the inspector are integers interpreted as percentages but, programmatically, you'd set the values using CGFloats in the range [0,1].

Of course, being a subclass of UIView, you can also customise the progress view's background color.

How to install:

Just copy the source file CircularProgressView.swift into your project. That's it. No frameworks.

Requirements:

I wrote this using Xcode 6.3 (6D570) and Swift 1.2.

Demo app:

I've added a demo app showing CircularProgressView in action on a typical scenario. All the app does is pretend to download information about characters from Game of Thrones. Of course, there's no actual downloading of anything; the data is all hardcoded into the app itself and the app simply counts until some number before it displays the data. Yes, the avatars are ugly. I originally wanted to have images from this page but then I'd be incurring on copyright violation so I opted for creating them myself. As you can see, I'm a great artist.

The demo app lets you play with the various options (other than color and thickness) by tapping on the corresponding buttons: clockwise/counterclockwise, normal/reversed mode, and show/hide percentage labels. The Reload button, well, reloads everything. The buttons affect all the progress views at once.

Creator

That would be me, Wagner Truppel. If you need or want to contact me, send a message to wagner at restlessbrain dot com.

License:

I'm sharing this work under the MIT License. See the LICENSE file for more information

More Repositories

1

Physics-Relativity-for-non-physicists

An essay about light, the appearance of objects, and the theory of relativity, for non-physicists.
7
star
2

iOS-Swift-Kaleidoscope

A simulation of a kaleidoscope, using UIKit Dynamics.
Swift
6
star
3

HTTPClient

An implementation of Dave DeLong's blog series on building a Swift HTTP framework.
Swift
5
star
4

Swift-WTUniquePrimitiveType

This project has been deprecated.
Swift
3
star
5

SwiftUI-TimingCurves

An app to explore animation timing curves in SwiftUI
Swift
3
star
6

Algs-Smoothing-Line-Segments

How to smooth a collection of points by interpolating them with Bezier curves.
Objective-C
2
star
7

Fiction-No-Time-Like-The-Present

2
star
8

Fiction

Short stories I've written over the years.
2
star
9

WTOpenSource

This repo collects in one place references to all my open-source contributions to development in Swift and for Apple platforms.
2
star
10

iOS-Swift-CGExtensions

This project has been DEPRECATED and replaced by separate libraries compatible with Swift 3.0. Please refer to WTOpenSource.
Swift
2
star
11

iOS-Swift-WTOnlineLinearRegressionDemo

A demo app for my WTOnlineLinearRegression library.
Swift
1
star
12

Physics

A collection of technical essays I've written over the years, on various topics in Physics.
1
star
13

Math-Principal-Component-Analysis

A review of PCA for a talk I gave in our research group at the UC Irvine’s Data Mining group.
1
star
14

Math-Sphere-Collision-Detection

How to analytically determine if two spheres will collide
1
star
15

ColorExtensions

Swift
1
star
16

Math-Solving-Polynomial-Equations

Complete analytical solution for general polynomial equations of degrees 3 and 4.
1
star
17

Algs-Discrete-Half-Flux-Diameter

A colleague interested in astrophotography asked me for an algorithm to compute the half-flux diameter of an image.
1
star
18

Swift-WTOnlineLinearRegression

WTOnlineLinearRegression lets you perform linear regression on one-dimensional data sets, with or without variance on the dependent variable.
Swift
1
star
19

Swift-WTCoreGraphicsExtensions

A collection of useful additions to `CGGradient`, `CGPoint` and, especially, `CGVector`.
Swift
1
star
20

iOS-Swift-WTAutoLayoutExtensions

Extensions to UIView and UILayoutGuide to make it simpler and more natural to use layout guides, layout anchors, and the rest of the auto-layout machinery, with a consistent API and very little code.
Swift
1
star
21

Physics-The-Equilibrium-of-a-Tilted-Soda-Can

Did you know that you can balance a partially filled soda can when it's tilted? Here I analyse the mathematics of why that is possible.
1
star