5 Commits

Author SHA1 Message Date
Alex.k 2c039420a0 made parentView open 2016-12-14 09:45:43 +03:00
aleksei1000000 9f42265ce4 Update README.md 2016-10-17 10:01:13 +03:00
aleksei1000000 75f7b8b8a6 Update README.md 2016-10-14 14:41:00 +03:00
aleksei1000000 1aca7f9b00 Update README.md 2016-10-14 14:06:39 +03:00
Alex.k 27189bd7e2 updated readme 2016-10-13 14:49:39 +03:00
3 changed files with 11 additions and 12 deletions
+7 -8
View File
@@ -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)
+2 -2
View File
@@ -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
+2 -2
View File
@@ -9,8 +9,8 @@
[![Analytics](https://ga-beacon.appspot.com/UA-84973210-1/ramotion/paper-switch)](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 well 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
[![PaperSwitch](https://raw.githubusercontent.com/Ramotion/paper-switch/master/screenshot.gif)](https://dribbble.com/shots/1749645-Contact-Sync)