Skip to content

Commit

Permalink
Really add the animation back
Browse files Browse the repository at this point in the history
  • Loading branch information
lucoceano committed Apr 12, 2016
1 parent d538cf8 commit 91355ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class ViewController: UIViewController {
if sender.selected {
sender.deselect()
} else {
sender.selectAnimated()
sender.select(animated: false)
}
}
}
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.6"
s.version = "0.0.7"
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
22 changes: 12 additions & 10 deletions DOFavoriteButton/DOFavoriteButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -371,19 +371,21 @@ public class DOFavoriteButton: UIButton {
selected = true
imageShape.fillColor = imageColorOn.CGColor

CATransaction.begin()
if animated {
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 91355ec

Please sign in to comment.