How to do it...

  1. Let's create a new Xcode project with the Single View Application template with the name BezierPath.
  2. The circular progress bar will consist of two layers: a fixed layer that will be added as a background for the progress bar and a progressive layer that will be animated.
  3. Now let's create a function that creates a circular layer so that we can reuse it for both layers. Add the following function in ViewController.swift:
 private func getShapeLayerForRect(rect:CGRect, strokeColor sColor:UIColor) -> CAShapeLayer{ let radius = rect.width / 2 - progressLineWidth / 2 let newRect = CGRect(x: progressLineWidth / 2, y: progressLineWidth / 2, width: radius * 2, height: radius * 2) let path = UIBezierPath(roundedRect: newRect, cornerRadius: ...

Get iOS Programming Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.