GithubHelp home page GithubHelp logo

polqf / fillableloaders Goto Github PK

View Code? Open in Web Editor NEW
2.1K 44.0 165.0 2.6 MB

Completely customizable progress based loaders drawn using custom CGPaths written in Swift

Home Page: https://cocoapods.org/pods/FillableLoaders

License: MIT License

Swift 97.52% Ruby 2.48%

fillableloaders's Introduction

Carthage compatible

FillableLoaders

Completely customizable progress based loaders drawn using custom CGPaths written in Swift

Waves

Plain

Spike

Rounded

Demo:

Changelog:

  • 1.3.0 (24 Sep 2016)
    • Swift 3.0
  • 1.2.6 (8 Apr 2016)
    • Fixing issue with width assert
    • Adapted to Swift 2.2
  • 1.2.5 (11 Dec 2015)
    • Precompiled framework using Xcode 7.2
  • 1.2.4 (28 Oct 2015)
    • Fixing issue when showing loader after removing it
  • 1.2.2 (27 Oct 2015)
    • Precompiled framework using Xcode 7.1
  • 1.2.1 (25 Oct 2015)
    • Added the possibility to add a loader to a desired UIView
    • Updated to Swift 2.0
  • 1.1.1 (2 Sep 2015)
    • Added Carthage Support
    • Added animation when hidding loader
  • 1.0.1 (17 Aug 2015)
    • Removed unused code
  • 1.0.0 (7 Aug 2015)
    • Progress based loaders 🎉
    • Added documentation to all the public properties and functions
  • 0.0.2 Initial Release (3 Aug 2015)

Quick Start:

- Progress based behaviour

Therea are only 2 necessary things to make the progress based loader work:

  • Create the loader using showProgressBasedLoaderWithPath(path:) or createProgressBasedLoaderWithPath(path:)
  • To update the fill progress, update the progress property of the loader, which goes from 0.0 to 1.0

- Creation

There are four main methods to create the loaders:

showProgressBasedLoaderWithPath(path:), createProgressBasedLoaderWithPath(path:),showLoaderWithPath(path:) and createLoaderWithPath(path:)

showLoaderWithPath(path:) or showProgressBasedLoaderWithPath(path:) are going to call the create one, and after it, are going to call the showLoader() method.

So, it is just a helper method to do everything at once.

If you want to create the loader, and not show it at the same moment, you can use createProgressBasedLoaderWithPath(path:) or createLoaderWithPath(path:) to create it, and when you want to show it, just call showLoader()

Sample code:

//PROGRESS BASED:
		
var loader = WavesLoader.createProgressBasedLoaderWithPath(path)
loader.loaderColor = UIColor.redColor()
        ...
//Do other stuff
        ...
loader.showLoader()
		
//BASIC

var loader = WavesLoader.createLoaderWithPath(path)
loader.loaderColor = UIColor.redColor()
        ...
//Do other stuff
        ...
loader.showLoader()

- Showing loader in desired view:

All the methods wave the variant version where you can pass it the view in which you want to add the loader:

  • showProgressBasedLoaderWithPath(path:onView:)
  • createProgressBasedLoaderWithPath(path:onView:)
  • showLoaderWithPath(path:onView:)
  • createLoaderWithPath(path:onView:)

- Deletion:

Just call the method removeLoader() and the loader will disappear and will also be removed from its superview.

Sample code:

loader.removeLoader()

Customization:

Apart from being able to customize the loader shape, you can also customize other properties of the loader. Take a look at the list:

  • progressBased: Bool Indicates if the loader movement is progress based or not (Default: false)
  • progress: CGFloat Loader fill progress from 0.0 to 1.0 . It will automatically fire an animation to update the loader fill progress
  • backgroundColor: UIColor?
    Background of the loader view (transparent by default)
  • loaderColor: UIColor?
    Color of the filled loader
  • loaderBackgroundColor: UIColor?
    Color of the unfilled loader
  • loaderStrokeColor: UIColor?
    Color of the path stroke
  • loaderStrokeWidth: CGFloat
    Width of the path stroke
  • loaderAlpha: CGFloat
    Alpha of the loader view (1.0 by default)
  • cornerRadius: CGFloat
    Corner radius of the loader view (0.0 by default)
  • duration: NSTimeInterval
    Duration of the animations (10.0 by default)
  • rectSize: CGFloat
    Height of the loader view
  • swing: Bool
    Bool to indicate if the loader has to swing when going up (small rotation, not available for the Plain loader)
Extra property for Spikes and Rounded loaders:
  • -spikeHeight: CGFloat Height of the spike

Installation:

• CocoaPods

use_frameworks!

pod 'FillableLoaders', '~>1.3.0'

• Carthage

github "poolqf/FillableLoaders" ~> "1.3.0"

• Manually

To manually add FillableLoaders to your project you just need to copy the Source folder files.

How to create my own CGPath?

⚠️ The CGPath bounds cannot exceed the bounds of the loaderView:
  • Width: Screen width
  • Height: rectSize property

• Manually

let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 0, height/2)
CGPathAddLineToPoint(path, nil, width + 100, height/2)
CGPathAddLineToPoint(path, nil, width + 100, height*2)
CGPathAddLineToPoint(path, nil, 0, height*2)
CGPathCloseSubpath(path)
return path

• PaintCode

PaintCode is a realy powerful Mac app that can do a lot of things. You can just draw things, and it will automagically create the code for you

In this case we can use it to create BezierPaths, and extract from there the CGPath.

In the case of drawing a star, it is going to give us this code:

//// Star Drawing
var starPath = UIBezierPath()
starPath.moveToPoint(CGPointMake(180, 25))
starPath.addLineToPoint(CGPointMake(195.16, 43.53))
starPath.addLineToPoint(CGPointMake(220.9, 49.88))
starPath.addLineToPoint(CGPointMake(204.54, 67.67))
starPath.addLineToPoint(CGPointMake(205.27, 90.12))
starPath.addLineToPoint(CGPointMake(180, 82.6))
starPath.addLineToPoint(CGPointMake(154.73, 90.12))
starPath.addLineToPoint(CGPointMake(155.46, 67.67))
starPath.addLineToPoint(CGPointMake(139.1, 49.88))
starPath.addLineToPoint(CGPointMake(164.84, 43.53))
starPath.closePath()
UIColor.grayColor().setFill()
starPath.fill()

The only thing we have to do here is extract the CGPath from the UIBezierPath like so:

let myPath = starPath.CGPath
var myLoader = WavesLoader.showProgressBasedLoaderWithPath(myPath)

• SVG + PaintCode

A feature that I LOVE from PaintCode is that you can import an .svg file, and it is going to create the code to create its BezierPath. Completely awesome.

That's how I did the Github and Twitter logos, for example.

Technical details:

  • Swift 3.0
  • Animations using CAKeyFrameAnimation

Licenses

All source code is licensed under the MIT License.

If you use it, i'll be happy to know about it.

Pol Quintana - @poolqf

fillableloaders's People

Contributors

armandgrillet avatar omaralbeik avatar polqf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fillableloaders's Issues

CocoaPod Version is wrong

Hey :)

Just want to inform you that the version 1.2.5 is not available as a pod. Last working version is currently 1.2.4. Did you push the pod spec? :)

Btw thanks for the awesome work and sharing it!

Manual Installation

CocoaPods and Carthage are awesome tools and make our life really easier, but there are some devs who still don't know how to use them.

It would be cool to add the Manual installation guide in your README.md. You can take a look at my iOS Readme Template to see how you can do it.

Renaming rectSize: CGFloat Height of the loader view

Great framework, it's awesome thank you for sharing. One improvement I would like to suggest is to either rename rectSize to height or actually make it a CGSize. I think making is a CGSize would be more work since it may alter the dimensions, but it should be renamed to height since it can be a little misleading. I'd be happy to make a PR.

Thread 1: Assertion failed: The width(387.0) of the path has to fit the dimensions (Height: 287.0 Width: 287.0)

I am getting following issue in FillableLoader.swift file when I implemet this

Thread 1: Assertion failed: The width(387.0) of the path has to fit the dimensions (Height: 287.0 Width: 287.0)

Below is my get path function

func getPath(height: Double, width: Double) -> CGPath { let path = CGMutablePath() path.move(to: CGPoint(x: 0, y: height/2)) path.addLine(to: CGPoint(x: width + 100, y: height/2)) path.addLine(to: CGPoint(x: width + 100, y: height*2)) path.addLine(to: CGPoint(x: 0, y: height*2)) path.closeSubpath() return path }

And here is code to perform animation

let loader = WavesLoader.createLoader(with: (getPath(height: Double(Int(cell.vwBarLayout.frame.size.height)), width: Double(Int(cell.vwBarLayout.frame.size.width)))), on: cell.vwBarLayout)//WavesLoader.createProgressBasedLoaderWithPath loader.loaderColor = UIColor.red

Always run into assertion

Hey there,

another question from my side. Whatever I do, my path is never fitting in your assertion and sometimes the debug makes no sense:

assertion failed: The width(243.65) of the path has to fit the dimensions (Height: 250.0 Width: 250.0): file /Users/ctews/Projects/Vukee/printME/Pods/FillableLoaders/Source/FillableLoader.swift, line 214

Also accessing the property for the height of the loaderView should be available as a param to the createWithPath(path) methods you supply.

I don't get what I'm doing wrong, it always runs into the assertion. I'm adding it onto a container view that is bigger than the path, but still not working. Here is the code in case it helps:

Path

let fillColor = UIColor(red: 0.970, green: 0.950, blue: 0.946, alpha: 1.000)
        let combinedShapePath = UIBezierPath()
        combinedShapePath.moveToPoint(CGPoint(x: 112.5, y: 110.64))
        combinedShapePath.addCurveToPoint(CGPoint(x: 143.41, y: 100.85), controlPoint1: CGPoint(x: 122.81, y: 107.41), controlPoint2: CGPoint(x: 133.14, y: 104.22))
        combinedShapePath.addCurveToPoint(CGPoint(x: 193.83, y: 128.47), controlPoint1: CGPoint(x: 160.23, y: 110.03), controlPoint2: CGPoint(x: 177.01, y: 119.29))
        combinedShapePath.addCurveToPoint(CGPoint(x: 221.17, y: 143.16), controlPoint1: CGPoint(x: 202.62, y: 133.92), controlPoint2: CGPoint(x: 211.92, y: 138.57))
        combinedShapePath.addCurveToPoint(CGPoint(x: 190.5, y: 115.95), controlPoint1: CGPoint(x: 211.03, y: 134.01), controlPoint2: CGPoint(x: 200.77, y: 124.97))
        combinedShapePath.addCurveToPoint(CGPoint(x: 221.17, y: 143.16), controlPoint1: CGPoint(x: 200.77, y: 124.97), controlPoint2: CGPoint(x: 211.03, y: 134.01))
        combinedShapePath.addCurveToPoint(CGPoint(x: 193.83, y: 128.47), controlPoint1: CGPoint(x: 211.92, y: 138.57), controlPoint2: CGPoint(x: 202.62, y: 133.92))
        combinedShapePath.addCurveToPoint(CGPoint(x: 191.31, y: 125.74), controlPoint1: CGPoint(x: 193.15, y: 127.42), controlPoint2: CGPoint(x: 192.45, y: 126.34))
        combinedShapePath.addCurveToPoint(CGPoint(x: 97.34, y: 68.73), controlPoint1: CGPoint(x: 159.94, y: 106.82), controlPoint2: CGPoint(x: 128.7, y: 87.67))
        combinedShapePath.addCurveToPoint(CGPoint(x: 94.12, y: 62.89), controlPoint1: CGPoint(x: 94.95, y: 67.74), controlPoint2: CGPoint(x: 94.42, y: 65.17))
        combinedShapePath.addCurveToPoint(CGPoint(x: 90.82, y: 28.47), controlPoint1: CGPoint(x: 93.02, y: 51.42), controlPoint2: CGPoint(x: 91.58, y: 39.96))
        combinedShapePath.addCurveToPoint(CGPoint(x: 159.69, y: 88.89), controlPoint1: CGPoint(x: 113.95, y: 48.41), controlPoint2: CGPoint(x: 136.73, y: 68.75))
        combinedShapePath.addCurveToPoint(CGPoint(x: 190.5, y: 115.95), controlPoint1: CGPoint(x: 169.93, y: 97.94), controlPoint2: CGPoint(x: 180.22, y: 106.94))
        combinedShapePath.addCurveToPoint(CGPoint(x: 159.69, y: 88.89), controlPoint1: CGPoint(x: 180.22, y: 106.94), controlPoint2: CGPoint(x: 169.93, y: 97.94))
        combinedShapePath.addCurveToPoint(CGPoint(x: 173.39, y: 57.39), controlPoint1: CGPoint(x: 162.96, y: 77.87), controlPoint2: CGPoint(x: 168.96, y: 67.95))
        combinedShapePath.addCurveToPoint(CGPoint(x: 195.81, y: 12.71), controlPoint1: CGPoint(x: 180.6, y: 42.37), controlPoint2: CGPoint(x: 188.33, y: 27.59))
        combinedShapePath.addCurveToPoint(CGPoint(x: 215.18, y: 26.82), controlPoint1: CGPoint(x: 202.7, y: 16.75), controlPoint2: CGPoint(x: 209.44, y: 21.22))
        combinedShapePath.addCurveToPoint(CGPoint(x: 233.53, y: 72.11), controlPoint1: CGPoint(x: 226.66, y: 38.95), controlPoint2: CGPoint(x: 232.35, y: 55.66))
        combinedShapePath.addCurveToPoint(CGPoint(x: 241.79, y: 158.17), controlPoint1: CGPoint(x: 236.28, y: 100.8), controlPoint2: CGPoint(x: 238.99, y: 129.49))
        combinedShapePath.addCurveToPoint(CGPoint(x: 88.08, y: 169.71), controlPoint1: CGPoint(x: 190.56, y: 162.12), controlPoint2: CGPoint(x: 139.31, y: 165.79))
        combinedShapePath.addCurveToPoint(CGPoint(x: 28.31, y: 160.65), controlPoint1: CGPoint(x: 67.9, y: 172.17), controlPoint2: CGPoint(x: 46.5, y: 170.33))
        combinedShapePath.addCurveToPoint(CGPoint(x: 11.4, y: 146.93), controlPoint1: CGPoint(x: 21.77, y: 157.36), controlPoint2: CGPoint(x: 16.01, y: 152.61))
        combinedShapePath.addCurveToPoint(CGPoint(x: 46.26, y: 133.07), controlPoint1: CGPoint(x: 22.86, y: 141.9), controlPoint2: CGPoint(x: 34.51, y: 137.36))
        combinedShapePath.addCurveToPoint(CGPoint(x: 11.4, y: 146.93), controlPoint1: CGPoint(x: 34.51, y: 137.36), controlPoint2: CGPoint(x: 22.86, y: 141.9))
        combinedShapePath.addLineToPoint(CGPoint(x: 11.26, y: 146.99))
        combinedShapePath.addCurveToPoint(CGPoint(x: -0.1, y: 109.03), controlPoint1: CGPoint(x: 2.57, y: 136.54), controlPoint2: CGPoint(x: -1.86, y: 122.57))
        combinedShapePath.addCurveToPoint(CGPoint(x: 24.84, y: 66.85), controlPoint1: CGPoint(x: 1.78, y: 92.23), controlPoint2: CGPoint(x: 11.84, y: 77.26))
        combinedShapePath.addCurveToPoint(CGPoint(x: 53.72, y: 51.76), controlPoint1: CGPoint(x: 33.32, y: 59.92), controlPoint2: CGPoint(x: 43.34, y: 55.1))
        combinedShapePath.addCurveToPoint(CGPoint(x: 58.66, y: 54.09), controlPoint1: CGPoint(x: 55.37, y: 52.51), controlPoint2: CGPoint(x: 57.08, y: 53.18))
        combinedShapePath.addCurveToPoint(CGPoint(x: 143.41, y: 100.85), controlPoint1: CGPoint(x: 86.68, y: 70.08), controlPoint2: CGPoint(x: 115.21, y: 85.17))
        combinedShapePath.addCurveToPoint(CGPoint(x: 112.5, y: 110.64), controlPoint1: CGPoint(x: 133.14, y: 104.22), controlPoint2: CGPoint(x: 122.81, y: 107.41))
        combinedShapePath.closePath()
        combinedShapePath.moveToPoint(CGPoint(x: 106.32, y: 12.19))
        combinedShapePath.addCurveToPoint(CGPoint(x: 157.95, y: 0.63), controlPoint1: CGPoint(x: 122, y: 3.68), controlPoint2: CGPoint(x: 140.07, y: -1.01))
        combinedShapePath.addCurveToPoint(CGPoint(x: 195.81, y: 12.71), controlPoint1: CGPoint(x: 171.28, y: 1.69), controlPoint2: CGPoint(x: 184.23, y: 6.09))
        combinedShapePath.addCurveToPoint(CGPoint(x: 173.39, y: 57.39), controlPoint1: CGPoint(x: 188.33, y: 27.59), controlPoint2: CGPoint(x: 180.6, y: 42.37))
        combinedShapePath.addCurveToPoint(CGPoint(x: 159.69, y: 88.89), controlPoint1: CGPoint(x: 168.96, y: 67.95), controlPoint2: CGPoint(x: 162.96, y: 77.87))
        combinedShapePath.addCurveToPoint(CGPoint(x: 90.82, y: 28.47), controlPoint1: CGPoint(x: 136.73, y: 68.75), controlPoint2: CGPoint(x: 113.95, y: 48.41))
        combinedShapePath.addCurveToPoint(CGPoint(x: 90.12, y: 27.87), controlPoint1: CGPoint(x: 90.64, y: 28.32), controlPoint2: CGPoint(x: 90.29, y: 28.02))
        combinedShapePath.addCurveToPoint(CGPoint(x: 106.32, y: 12.19), controlPoint1: CGPoint(x: 94.04, y: 21.35), controlPoint2: CGPoint(x: 99.65, y: 15.86))
        combinedShapePath.closePath()
        combinedShapePath.moveToPoint(CGPoint(x: 58.66, y: 54.09))
        combinedShapePath.addCurveToPoint(CGPoint(x: 67.92, y: 57.05), controlPoint1: CGPoint(x: 61.9, y: 54.56), controlPoint2: CGPoint(x: 64.86, y: 56))
        combinedShapePath.addCurveToPoint(CGPoint(x: 94.23, y: 66.52), controlPoint1: CGPoint(x: 76.71, y: 60.15), controlPoint2: CGPoint(x: 85.44, y: 63.42))
        combinedShapePath.addCurveToPoint(CGPoint(x: 94.12, y: 62.89), controlPoint1: CGPoint(x: 94.2, y: 65.61), controlPoint2: CGPoint(x: 94.15, y: 63.8))
        combinedShapePath.addCurveToPoint(CGPoint(x: 97.34, y: 68.73), controlPoint1: CGPoint(x: 94.42, y: 65.17), controlPoint2: CGPoint(x: 94.95, y: 67.74))
        combinedShapePath.addCurveToPoint(CGPoint(x: 191.31, y: 125.74), controlPoint1: CGPoint(x: 128.7, y: 87.67), controlPoint2: CGPoint(x: 159.94, y: 106.82))
        combinedShapePath.addCurveToPoint(CGPoint(x: 193.83, y: 128.47), controlPoint1: CGPoint(x: 192.45, y: 126.34), controlPoint2: CGPoint(x: 193.15, y: 127.42))
        combinedShapePath.addCurveToPoint(CGPoint(x: 143.41, y: 100.85), controlPoint1: CGPoint(x: 177.01, y: 119.29), controlPoint2: CGPoint(x: 160.23, y: 110.03))
        combinedShapePath.addCurveToPoint(CGPoint(x: 58.66, y: 54.09), controlPoint1: CGPoint(x: 115.21, y: 85.17), controlPoint2: CGPoint(x: 86.68, y: 70.08))
        combinedShapePath.closePath()
        combinedShapePath.miterLimit = 4;

        combinedShapePath.usesEvenOddFillRule = true;

        fillColor.setFill()
        combinedShapePath.fill()

Specific UIView Container

    override init(frame: CGRect) {
        super.init(frame: CGRect(x: frame.origin.x, y: frame.origin.y, width: 250, height: 200))
        self.loader = self.createLoader(self)
    }

Freeze whole application

i have application with only tableview and collection view . When i add it in 2 3 view controller my whole application gets freezes. when i removed it application work proper.
You have any solution related to it?

Problem Swift 2.3

Here the problems:

  • ERROR: RoundedLoader.swift:68:26: Method does not override any method from its superclass
override public func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        guard animate, let key = anim.valueForKey("animation") as? String else { return }
        if key == "up" {
            startMoving(up: false)
        }
        else if key == "down" {
            startMoving(up: true)
        }
        if key == "rotation" {
            startswinging()
        }
    }
  • PlainLoader.swift:46:26: Method does not override any method from its superclass
override public func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        guard animate, let key = anim.valueForKey("animation") as? String else { return }
        if key == "up" {
            startMoving(up: false)
        }
        else if key == "down" {
            startMoving(up: true)
        }
        if key == "rotation" {
            startswinging()
        }
    }
  • ERROR: FillableLoader.swift:315:34: Cannot assign value of type 'FillableLoader' to type
    'CAAnimationDelegate?'
internal func startMoving(up up: Bool) {
        if (progressBased) { return }
        let key = up ? "up" : "down"
        let moveAnimation: CAKeyframeAnimation = CAKeyframeAnimation(keyPath: "position.y")
        moveAnimation.values = up ? [loaderView.frame.height/2 + rectSize/2, loaderView.frame.height/2 - rectSize/2 - extraHeight] : [loaderView.frame.height/2 - rectSize/2 - extraHeight, loaderView.frame.height/2 + rectSize/2]
        moveAnimation.duration = duration
        moveAnimation.removedOnCompletion = false
        moveAnimation.fillMode = kCAFillModeForwards
        moveAnimation.delegate = self
        moveAnimation.setValue(key, forKey: "animation")
        shapeLayer.addAnimation(moveAnimation, forKey: key)
    }
  • ERROR: FillableLoader.swift:337:35: Cannot assign value of type 'FillableLoader' to type 'CAAnimationDelegate?'
internal func startswinging() {
        let swingAnimation: CAKeyframeAnimation = CAKeyframeAnimation(keyPath: "transform.rotation.z")
        swingAnimation.values = [0, randomAngle(), -randomAngle(), randomAngle(), -randomAngle(), randomAngle(), 0]
        swingAnimation.duration = 12.0
        swingAnimation.removedOnCompletion = false
        swingAnimation.fillMode = kCAFillModeForwards
        swingAnimation.delegate = self
        swingAnimation.setValue("rotation", forKey: "animation")
        shapeLayer.addAnimation(swingAnimation, forKey: "rotation")
    }
  • ERROR: WavesLoader.swift:101:26: Method does not override any method from its superclass
override public func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        guard animate, let key = anim.valueForKey("animation") as? String else { return }
        if key == "up" {
            startMoving(up: false)
        }
        else if key == "down" {
            startMoving(up: true)
        }
        if key == "shape" {
            startWaving()
        }
        if key == "rotation" {
            startswinging()
        }
    }
  • ERROR: WavesLoader.swift:39:34: Cannot assign value of type 'WavesLoader' to type 'CAAnimationDelegate?'
internal func startWaving() {
        let waveAnimation: CAKeyframeAnimation = CAKeyframeAnimation(keyPath: "path")
        waveAnimation.values = shapesArray(7)
        waveAnimation.duration = 2.0
        waveAnimation.removedOnCompletion = false
        waveAnimation.fillMode = kCAFillModeForwards
        waveAnimation.delegate = self
        waveAnimation.setValue("shape", forKey: "animation")
        shapeLayer.addAnimation(waveAnimation, forKey: "shape")
    }
  • ERROR: SpikeLoader.swift:62:26: Method does not override any method from its superclass
override public func animationDidStop(anim: CAAnimation, finished flag: Bool) {
        guard animate, let key = anim.valueForKey("animation") as? String else { return }
        if key == "up" {
            startMoving(up: false)
        }
        else if key == "down" {
            startMoving(up: true)
        }
        if key == "rotation" {
            startswinging()
        }
    }

Is there a way to specify the rectSize?

Hi, this is a wonderful project, thanks for providing this framework. but when I use this framework I can't set a value to rectSize due to I don't want to use the default one. So I add one function as below:

 public static func createProgressBasedLoaderWithPathWithHeight(path thePath: CGPath, theHeight: CGFloat, onView: UIView? = nil) -> Self
    {
        let loader = self.init()

        loader.progressBased = true
        loader.rectSize = theHeight;
        loader.initialSetup(onView)
        loader.addPath(thePath)
        return loader
    }

Is this reasonable ? Thanks
Leslie

Renaming rectSize: CGFloat Height of the loader view

Great framework, it's awesome thank you for sharing. One improvement I would like to suggest is to either rename rectSize to height or actually make it a CGSize. I think making is a CGSize would be more work since it may alter the dimensions, but it should be renamed to height since it can be a little misleading. I'd be happy to make a PR.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.