-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
37 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
// | ||
// HasAnimatablePath.swift | ||
// HasAnimatableLayer.swift | ||
// NativePopup | ||
// | ||
// Created by mono on 2017/05/21. | ||
// Created by mono on 2017/05/20. | ||
// Copyright © 2017 mono. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
public protocol HasAnimatablePath: HasAnimatableLayer { | ||
public protocol HasAnimatablePath: Animatable { | ||
var layer: CALayer { get } | ||
var tintColor: UIColor! { get } | ||
/** Should return same instance */ | ||
var animatableLayer: CAShapeLayer { get } | ||
var animatablePath: UIBezierPath { get } | ||
func setupLayer() | ||
} | ||
|
||
public extension HasAnimatablePath where Self: UIView { | ||
public func setupLayer() { | ||
public extension HasAnimatablePath { | ||
public func animate() { | ||
let animation = CABasicAnimation(keyPath: "strokeEnd") | ||
animation.duration = duration | ||
animation.fromValue = 0 | ||
animation.toValue = 1 | ||
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) | ||
animatableLayer.strokeEnd = 1 | ||
animatableLayer.add(animation, forKey: "animation") | ||
} | ||
public func configureAnimatableLayer() { | ||
animatableLayer.path = animatablePath.cgPath | ||
animatableLayer.fillColor = UIColor.clear.cgColor | ||
animatableLayer.strokeColor = tintColor.cgColor | ||
animatableLayer.strokeColor = tintColor?.cgColor | ||
animatableLayer.lineWidth = 9 | ||
animatableLayer.lineCap = kCALineCapRound | ||
animatableLayer.lineJoin = kCALineCapRound | ||
animatableLayer.strokeEnd = 0 | ||
layer.addSublayer(animatableLayer) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters