polqf / fillableloaders Goto Github PK
View Code? Open in Web Editor NEWCompletely customizable progress based loaders drawn using custom CGPaths written in Swift
Home Page: https://cocoapods.org/pods/FillableLoaders
License: MIT License
Completely customizable progress based loaders drawn using custom CGPaths written in Swift
Home Page: https://cocoapods.org/pods/FillableLoaders
License: MIT License
Here the problems:
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()
}
}
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()
}
}
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)
}
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")
}
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()
}
}
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")
}
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()
}
}
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
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.
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!
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.
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?
When I add this to my project via cocoa pods, its missing the function to set the mainBgColor.
Is there any way to update the version on cocoa pods?
Is there any method or event that notifies me that the loader finished it's job? I want to show another animations after the loader finished the progress animation.
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)
}
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.