Skip to content

Commit 0b12848

Browse files
committed
fixed issue #4
1 parent 2f9bfe5 commit 0b12848

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

DOFavoriteButton/DOFavoriteButton.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class DOFavoriteButton: UIButton {
1717
private var imageShape: CAShapeLayer!
1818
@IBInspectable public var image: UIImage! {
1919
didSet {
20-
imageShape.mask.contents = image.CGImage
20+
createLayers(image: image)
2121
}
2222
}
2323
@IBInspectable public var imageColorOn: UIColor! = UIColor(red: 255/255, green: 172/255, blue: 51/255, alpha: 1.0) {
@@ -104,6 +104,7 @@ public class DOFavoriteButton: UIButton {
104104
}
105105

106106
private func createLayers(#image: UIImage!) {
107+
self.layer.sublayers = nil
107108

108109
let imageFrame = CGRectMake(frame.size.width / 2 - frame.size.width / 4, frame.size.height / 2 - frame.size.height / 4, frame.size.width / 2, frame.size.height / 2)
109110
let imgCenterPoint = CGPointMake(imageFrame.origin.x + imageFrame.width / 2, imageFrame.origin.y + imageFrame.height / 2)

0 commit comments

Comments
 (0)