Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2c039420a0 | |||
| 9f42265ce4 | |||
| 75f7b8b8a6 | |||
| 1aca7f9b00 | |||
| 27189bd7e2 |
@@ -45,7 +45,11 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
|
||||
fileprivate var oldState = false
|
||||
|
||||
fileprivate var defaultTintColor: UIColor?
|
||||
fileprivate(set) var parentView: UIView?
|
||||
@IBOutlet open var parentView: UIView? {
|
||||
didSet {
|
||||
defaultTintColor = parentView?.backgroundColor
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
@@ -68,18 +72,17 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
|
||||
}
|
||||
|
||||
override open func awakeFromNib() {
|
||||
self.commonInit(superview)
|
||||
self.commonInit(parentView ?? superview)
|
||||
super.awakeFromNib()
|
||||
}
|
||||
|
||||
// MARK: Helpers
|
||||
|
||||
fileprivate func commonInit(_ parentView: UIView?) {
|
||||
guard let onTintColor = self.onTintColor else {
|
||||
fatalError("set tint color")
|
||||
}
|
||||
self.parentView = parentView
|
||||
self.defaultTintColor = parentView?.backgroundColor
|
||||
defaultTintColor = parentView?.backgroundColor
|
||||
|
||||
layer.borderWidth = 0.5
|
||||
layer.borderColor = UIColor.white.cgColor
|
||||
@@ -107,7 +110,6 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
open override func setOn(_ on: Bool, animated: Bool) {
|
||||
let changed:Bool = on != self.isOn
|
||||
|
||||
@@ -119,7 +121,6 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
fileprivate func showShapeIfNeed() {
|
||||
shape.transform = isOn ? CATransform3DMakeScale(1.0, 1.0, 1.0) : CATransform3DMakeScale(0.0001, 0.0001, 0.0001)
|
||||
}
|
||||
@@ -129,7 +130,6 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
|
||||
}
|
||||
|
||||
// MARK: - Animations
|
||||
|
||||
fileprivate func animateKeyPath(_ keyPath: String, fromValue from: CGFloat?, toValue to: CGFloat, timing timingFunction: String) -> CABasicAnimation {
|
||||
|
||||
let animation:CABasicAnimation = CABasicAnimation(keyPath: keyPath)
|
||||
@@ -173,7 +173,6 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
|
||||
}
|
||||
|
||||
//MARK: - CAAnimation Delegate
|
||||
|
||||
open func animationDidStart(_ anim: CAAnimation) {
|
||||
parentView?.backgroundColor = defaultTintColor
|
||||
animationDidStartClosure(isOn)
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
Pod::Spec.new do |s|
|
||||
s.name = 'RAMPaperSwitch'
|
||||
s.version = '2.0.0'
|
||||
s.version = '2.0.2'
|
||||
s.summary = 'Swift subclass of the UISwitch which paints over the parent view'
|
||||
s.homepage = 'https://github.com/Ramotion/paper-switch'
|
||||
s.license = 'MIT'
|
||||
s.author = { 'juri.v' => 'juri.v@ramotion.com' }
|
||||
s.source = { :git => 'https://github.com/Ramotion/paper-switch.git', :tag => s.version.to_s }
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.ios.deployment_target = '9.0'
|
||||
s.source_files = 'PaperSwitch/*.swift'
|
||||
end
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
[](https://github.com/igrigorik/ga-beacon)
|
||||
|
||||
## About
|
||||
This project is maintained by Ramotion, an agency specialized in building dedicated engineering teams and developing custom software.<br><br> [Contact our team](https://business.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=paper-switch-contact-us) and we’ll help you work with the best engineers from Eastern Europe.
|
||||
|
||||
This project is maintained by Ramotion, Inc.<br>
|
||||
We specialize in the designing and coding of custom UI for Mobile Apps and Websites.<br><br>**Looking for developers for your project?** [[▶︎CONTACT OUR TEAM◀︎](http://business.ramotion.com?utm_source=gthb&utm_medium=special&utm_campaign=paper-switch-contact-us/#Get_in_Touch)]
|
||||
|
||||
#Screenshot
|
||||
[](https://dribbble.com/shots/1749645-Contact-Sync)
|
||||
|
||||
Reference in New Issue
Block a user