Skip to content

Commit

Permalink
Remove the option to be animated
Browse files Browse the repository at this point in the history
  • Loading branch information
lucoceano committed Apr 12, 2016
1 parent 8db1f4d commit ba3eb60
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
4FBAA7081B4D807F00C8657F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA7061B4D807F00C8657F /* Main.storyboard */; };
4FBAA70A1B4D807F00C8657F /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA7091B4D807F00C8657F /* Images.xcassets */; };
4FBAA70D1B4D807F00C8657F /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4FBAA70B1B4D807F00C8657F /* LaunchScreen.xib */; };
C851CA7B1CBD397200B073FB /* DOFavoriteButton.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F60711B1B6366ED0058F570 /* DOFavoriteButton.framework */; };
/* End PBXBuildFile section */

/* Begin PBXBuildRule section */
Expand Down Expand Up @@ -54,6 +55,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
C851CA7B1CBD397200B073FB /* DOFavoriteButton.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
10 changes: 5 additions & 5 deletions DOFavoriteButton-DEMO/DOFavoriteButton-DEMO/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ViewController: UIViewController {

// star button
let starButton = DOFavoriteButton(frame: CGRectMake(x, y, 44, 44), image: UIImage(named: "star"))
starButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside)
starButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(starButton)
x += width

Expand All @@ -31,7 +31,7 @@ class ViewController: UIViewController {
heartButton.imageColorOn = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0)
heartButton.circleColor = UIColor(red: 254/255, green: 110/255, blue: 111/255, alpha: 1.0)
heartButton.lineColor = UIColor(red: 226/255, green: 96/255, blue: 96/255, alpha: 1.0)
heartButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside)
heartButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(heartButton)
x += width

Expand All @@ -40,7 +40,7 @@ class ViewController: UIViewController {
likeButton.imageColorOn = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0)
likeButton.circleColor = UIColor(red: 52/255, green: 152/255, blue: 219/255, alpha: 1.0)
likeButton.lineColor = UIColor(red: 41/255, green: 128/255, blue: 185/255, alpha: 1.0)
likeButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside)
likeButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(likeButton)
x += width

Expand All @@ -49,10 +49,10 @@ class ViewController: UIViewController {
smileButton.imageColorOn = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0)
smileButton.circleColor = UIColor(red: 45/255, green: 204/255, blue: 112/255, alpha: 1.0)
smileButton.lineColor = UIColor(red: 45/255, green: 195/255, blue: 106/255, alpha: 1.0)
smileButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside)
smileButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(smileButton)

self.heartButton.addTarget(self, action: Selector("tappedButton:"), forControlEvents: UIControlEvents.TouchUpInside)
self.heartButton.addTarget(self, action: #selector(ViewController.tappedButton(_:)), forControlEvents: UIControlEvents.TouchUpInside)
}

override func didReceiveMemoryWarning() {
Expand Down
2 changes: 1 addition & 1 deletion DOFavoriteButton.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DOFavoriteButton"
s.version = "0.0.4"
s.version = "0.0.5"
s.summary = "Cute Animated Button written in Swift. It could be just right for favorite buttons!"
s.homepage = "https://github.com/okmr-d/DOFavoriteButton"
s.screenshots = "https://raw.githubusercontent.com/okmr-d/okmr-d.github.io/master/img/DOFavoriteButton/demo.gif"
Expand Down
28 changes: 11 additions & 17 deletions DOFavoriteButton/DOFavoriteButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,28 +364,22 @@ public class DOFavoriteButton: UIButton {
}

public func select() {
select(true)
}

public func select(animate animate: Bool) {
selected = true
imageShape.fillColor = imageColorOn.CGColor

if animate {
CATransaction.begin()

CATransaction.begin()

circleShape.addAnimation(circleTransform, forKey: "transform")
circleMask.addAnimation(circleMaskTransform, forKey: "transform")
imageShape.addAnimation(imageTransform, forKey: "transform")
circleShape.addAnimation(circleTransform, forKey: "transform")
circleMask.addAnimation(circleMaskTransform, forKey: "transform")
imageShape.addAnimation(imageTransform, forKey: "transform")

for i in 0 ..< 5 {
lines[i].addAnimation(lineStrokeStart, forKey: "strokeStart")
lines[i].addAnimation(lineStrokeEnd, forKey: "strokeEnd")
lines[i].addAnimation(lineOpacity, forKey: "opacity")
}
for i in 0 ..< 5 {
lines[i].addAnimation(lineStrokeStart, forKey: "strokeStart")
lines[i].addAnimation(lineStrokeEnd, forKey: "strokeEnd")
lines[i].addAnimation(lineOpacity, forKey: "opacity")
}

CATransaction.commit()
}
CATransaction.commit()
}

public func deselect() {
Expand Down

0 comments on commit ba3eb60

Please sign in to comment.