yannickl / dynamicbutton Goto Github PK
View Code? Open in Web Editor NEWYet another animated flat buttons in Swift
Home Page: http://cocoadocs.org/docsets/DynamicButton
License: MIT License
Yet another animated flat buttons in Swift
Home Page: http://cocoadocs.org/docsets/DynamicButton
License: MIT License
Here is the code for reload icon.
class ReloadDynamicButton: DynamicButtonStyle {
convenience required init(center: CGPoint, size: CGFloat, offset: CGPoint, lineWidth: CGFloat) {
let curveBezierPath = UIBezierPath(arcCenter: center, radius: size / 3, startAngle: 0.0, endAngle: CGFloat((3.0 * M_PI) / 2), clockwise: true)
let path: CGPathRef = curveBezierPath.CGPath
let curveEndPoint = curveBezierPath.currentPoint
let thirdSize = size / 6
let sixthSize = size / 12
let a = CGPoint(x: center.x + sixthSize, y: center.y)
let b = CGPoint(x: center.x - sixthSize, y: center.y + thirdSize)
let c = CGPoint(x: center.x - sixthSize, y: center.y - thirdSize)
let gravityCenter = CGPoint(x: (a.x + b.x + c.x) / 3, y: (a.y + b.y + c.y) / 3)
let offsetFromCenter = CGPoint(x: curveEndPoint.x - gravityCenter.x, y: curveEndPoint.y - gravityCenter.y)
let path1 = CGPathCreateMutable()
CGPathMoveToPoint(path1, nil, offset.x + a.x, offsetFromCenter.y + a.y)
CGPathAddLineToPoint(path1, nil, offset.x + b.x, offsetFromCenter.y + b.y)
let path2 = CGPathCreateMutable()
CGPathMoveToPoint(path1, nil, offset.x + a.x, offsetFromCenter.y + a.y)
CGPathAddLineToPoint(path1, nil, offset.x + c.x, offsetFromCenter.y + c.y)
self.init(path1: path, path2: path1, path3: path2, path4: path1)
}
}
The button contentInset should affect the style draw but it does not affect the position. It only takes into account the new size.
It would be nice to be able to create custom buttons, perhaps with a function that can be fed CGPathRef
s:
let startCustomButton = DynamicButton(startLine1, startLine2, startLine3, startLine4)
let endCustomButton = DynamicButton(endLine1, endLine2, endLine3, endLine4)
startCustomButton.setStyle(endCustomButton.style, animated: true)
( maybe even use ASCIImage - cparnot/ASCIImage#12 )
Create a new swift3
branch and update the APIs to be conform to the Swift API Guideline.
^
See the https://github.com/yannickl/DynamicButton/tree/swift4 branch
2018-12-20 11:33:59.954669-0600 PUBGStats[10256:112849] Unknown class DynamicButton in Interface Builder file.
2018-12-20 11:33:59.956261-0600 PUBGStats[10256:112849] +[UILabel removeAllAnimations]: unrecognized selector sent to class 0x113317ce0
2018-12-20 11:33:59.962764-0600 PUBGStats[10256:112849] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UILabel removeAllAnimations]: unrecognized selector sent to class 0x113317ce0'
Hi!
I'm creating a hamburger button using
button = DynamicButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
button.lineWidth = 4
button.setStyle(.hamburger, animated: false)
Now, the Hamburger has square tips,
but the Close icon has rounded tips
The documentation shows a hamburger icon with rounded tips, so I'm wondering. Am I doing something wrong? or is there something I can set in order to achieve that?
thank you!
Installation of via SPM fails:
The package dependency graph can not be resolved; unable find any available tag for the following requirements:
https://github.com/yannickl/DynamicButton โ 6.2.0..<7.0.0
Thank you I needed this
It would be great if the voice over response could be set.
Creating a custom DynamicButtonBuildableStyle in Swift 4 yields the following compile error:
'DynamicButtonPathVector' initializer is inaccessible due to 'internal' protection level
When trying to create a DynamicButtonPathVector(p1: CGMutablePath(), p2: CGMutablePath(), p3: CGMutablePath(), p4: CGMutablePath())
I have a fix for this and I will send a PR for it.
I'm trying to set an image as background, it works but the image is like stretched out - very ugly lol. Is there a way to fix that? or am I doing something wrong with the image?
I added a button on interface builder. Set up click event. When changing the style, the animation is not working. The style does change, but without animation
The compiler's reporting the following problem:
/Users/hkatz/DynamicButton/Sources/DynamicButtonStyle.swift:177:14: 'Hashable.hashValue' is deprecated as a protocol requirement; conform type 'DynamicButton.Style' to 'Hashable' by implementing 'hash(into:)' instead
I think I could likely fix this and do a pull request on it, but I've never done that and don't have the time at the moment to figure it out. Soon tho! :-)
Use of unresolved identifier 'PathHelper'
when I'm trying to call
PathHelper.line(atCenter: center, radius: size / 2, angle: PathHelper.F_PI_2)
Xcode 8, Swift 3, 1.1.0.rc2
Hi! I appreciate your work and I'm loving it! But I've been struggling to set title for a button, here's my code but it's not working.
let confirm_button = DynamicButton()
confirm_button.setTitle("Confirm", forState: .Normal)
confirm_button.setTitleColor(UIColor.blackColor(), forState: .Normal)
confirm_button.backgroundColor = UIColor.bluecolor()
The above code executes perfectly but the button only shows background color but not the title. Is there a way to to so?
@yannickl
For the DynamicButtonStyle.arrowUp
I'm trying to round it but i end up with the arrow at the top instead of center. how come? Could you make it possible to adjust icon size and properly align it in the center
Currently, if you call layoutsubviews while the button is animating, setStyle(buttonStyle, animated: false)
will be called and hence the animation will complete instantly.
Since my button animates the view it is in, layoutsubviews is called several times during the transition and hence the button doesn't work.
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.