How to write Kickass Animated Circle Progress Bar (Ep 1)
Why Stack Overflow recommends it
Stack Overflow users link it when asked how to build a circular progress or loading indicator on iOS, and askers often cite it as the guide their own code is based on.
Recommended by 1 people across 1 different months, 2018 to 2021.
What it is
A short iOS tutorial by Brian Voong (Lets Build That App) showing how to build an animated circular progress bar in Swift. It draws a circle with CAShapeLayer and UIBezierPath and animates the stroke using CABasicAnimation.
What people said
Recommends naeemjawaid · 2018-01 · Stack Overflow · on “Name of spinner/progress/indicator component”
Its called circular progress view in general. iOS framework doesn't provide such a component. The closest is UIActivityIndicatorView. You can use an open-source MBCircularProgressBar: [LINK] Otherwise if you want to learn how its made than follow along Brian Voong's (Lets Build That App) tutorial on this topic here: [this video] PS: Wait for the second episode of the tutorial series.
Cites Edouard Barbier · 2018-02 · Stack Overflow · on “Circular BezierPath fills too much vs. given progress value - iOS Swift”
I have a circular UIBezierPath & 2x CAShapeLayers that I use to display the progress towards a specific milestone in one of my apps. Problem: when I animate the progress via CABasicAnimation, the progress goes beyond what it should be doing. Context: I display this circularView in a subview of a custom cell inside my milestonesCollectionView. View Hierarchy: CollectionView > Custom Cell > subview > drawRect to create & add the layers there. My code: Custom Cell Inside my custom cell I setup the currentProgress (hardcoded for now for testing purpose) let placeHolderForProgressView: CircularTrackerView = { let ctv = CircularTrackerView() ctv.backgroundColor = UIColor.clear ctv.translatesAutore
Cites HiDungLing · 2020-01 · Stack Overflow · on “Issue with CABasicAnimation”
So basically I am trying to create dialogView. This dialogView will contain a loading spinner and some text which will be updated depending on the state. I followed two guides to use a CAShapeLayer to draw a circle and then animate a line around it. Link to code/guides I followed [this video] [LINK] Despite following most of these tutorials to the tee. My animation will not work. At the moment it just looks like this and will not spin. [LINK] class LoginDialogView: UIViewController { lazy var loaderView: UIView = { let loaderView = UIView() loaderView.backgroundColor = .yellow return loaderView }() lazy var dialogTitle : UILabel = { let dialogTitle = UILabel() dialogTitle.text = "Apples" dialogTi
Cites Ehi Airewele · 2020-11 · Stack Overflow · on “CAShapeLayer is added to the view, but not around my button”
I'd like to add a circular CAShapeLayer around my button that I've implemented with Storyboard. I'm doing this because I want to add a clockwise circle and pulsing animation similar to these two videos: #1 [this video] and #2 [LINK] . I don't want a border as a shape is required. I've tried two approaches to and it is not going directly around my button. I've tried it with viewDidLoad and viewDidLayoutSubviews. Both approaches put it in the top left corner. For brevity's sake, I only attached the viewDidLayoutSubviews below. The only change in viewDidLoad is the addition of self.view.layoutIfNeeded(). var wasCAShapeLayerAddedToButton = false override func viewDidLayoutSubviews() { super.viewDidLa
Cites user15748784 · 2021-12 · Stack Overflow · on “How to make circular loading animation color go from red to green as it loads”
I have implemented a circular loading animation exactly as in this video: [this video] Here is my code: class ViewController: UIViewController { let shapeLayer = CAShapeLayer() override func viewDidLoad() { super.viewDidLoad() let center = view.center let trackLayer = CAShapeLayer() let circularPath = UIBezierPath(arcCenter: center, radius: 100, startAngle: -CGFloat.pi / 2, endAngle: 2 * CGFloat.pi, clockwise: true) trackLayer.path = circularPath.cgPath trackLayer.strokeColor = UIColor.lightGray.cgColor trackLayer.lineWidth = 10 trackLayer.fillColor = UIColor.clear.cgColor trackLayer.lineCap = kCALineCapRound view.layer.addSublayer(trackLayer) shapeLayer.path = circularPath.cgPath shapeLayer.stro