Git Product home page Git Product logo

dynamicbutton's People

Contributors

aasatt avatar victorwon avatar yannickl 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

dynamicbutton's Issues

Annoying animation with custom shapes

annoying animation

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)
}
}

Content inset does not work

The button contentInset should affect the style draw but it does not affect the position. It only takes into account the new size.

Custom button symbols

It would be nice to be able to create custom buttons, perhaps with a function that can be fed CGPathRefs:

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 )

Unknown class DynamicButton in Interface Builder file

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'

Hamburger icon with rounded tips

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,

image

but the Close icon has rounded tips

image

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!

Swift package manager fails in Xcode 11

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

Voice Over

It would be great if the voice over response could be set.

DynamicButtonPathVector

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.

image is stretched out if set as background

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?

DynamicButton.Style needs a hash(into:) method to conform to Hashable

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! :-)

PathHelper is unresolved

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

SetTitle doesn't work?

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?

Button Icon Size + Round Background

@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

Calling layoutsubviews should not interrupt an existing transition

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.

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.