12 Commits

Author SHA1 Message Date
Alex.k 9c78c75046 fixed bug with position 2016-12-14 10:43:41 +03:00
Alex.k 6d2380f065 updated podspec and readme 2016-12-14 09:48:45 +03:00
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
Alex.k 269a4a0036 updated settings 2016-10-13 14:45:52 +03:00
Alex.k 779c80b2f5 Merge branch 'master' of https://github.com/Ramotion/paper-switch 2016-10-13 14:29:03 +03:00
Alex.k 9bd7a42e2f update settings 2016-10-13 14:28:58 +03:00
aleksei1000000 db7ba38c71 Update README.md 2016-09-29 17:10:37 +03:00
Alex.k 937322b2b6 update readme 2016-09-23 10:13:42 +03:00
6 changed files with 35 additions and 30 deletions
+16 -12
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
@@ -97,17 +100,21 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
}
override open func layoutSubviews() {
let x:CGFloat = max(frame.midX, superview!.frame.size.width - frame.midX);
let y:CGFloat = max(frame.midY, superview!.frame.size.height - frame.midY);
radius = sqrt(x*x + y*y);
if let parentView = self.parentView {
let x:CGFloat = max(center.x, parentView.frame.size.width - frame.midX)
let y:CGFloat = max(center.y, parentView.frame.size.height - frame.midY)
radius = sqrt(x*x + y*y)
}
let additional = parentView == superview ? CGPoint.zero : (superview?.frame.origin ?? CGPoint.zero)
shape.frame = CGRect(x: frame.midX - radius, y: frame.midY - radius, width: radius * 2, height: radius * 2)
shape.frame = CGRect(x: center.x - radius + additional.x - 2, y: center.y - radius + additional.y, width: radius * 2, height: radius * 2)
shape.anchorPoint = CGPoint(x: 0.5, y: 0.5);
shape.path = UIBezierPath(ovalIn: CGRect(x: 0, y: 0, width: radius * 2, height: radius * 2)).cgPath
}
// MARK: - Public
open override func setOn(_ on: Bool, animated: Bool) {
let changed:Bool = on != self.isOn
@@ -119,7 +126,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 +135,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 +178,6 @@ open class RAMPaperSwitch: UISwitch, CAAnimationDelegate {
}
//MARK: - CAAnimation Delegate
open func animationDidStart(_ anim: CAAnimation) {
parentView?.backgroundColor = defaultTintColor
animationDidStartClosure(isOn)
BIN
View File
Binary file not shown.
@@ -265,6 +265,7 @@
TargetAttributes = {
84BE57D11CFF03ED0073C92B = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 34MUF9YXTA;
LastSwiftMigration = 0800;
};
9C6889F91A274993008BFF1E = {
@@ -373,17 +374,18 @@
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ANALYZER_NONNULL = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CURRENT_PROJECT_VERSION = 1;
DEBUG_INFORMATION_FORMAT = dwarf;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = 34MUF9YXTA;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = PaperSwitch/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.PaperSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -409,7 +411,7 @@
GCC_NO_COMMON_BLOCKS = YES;
INFOPLIST_FILE = PaperSwitch/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.PaperSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -458,7 +460,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -499,7 +501,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -516,9 +518,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = PaperSwitchDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "ramotion.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
@@ -531,9 +533,9 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = "";
INFOPLIST_FILE = PaperSwitchDemo/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "ramotion.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.dev;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
};
+2 -2
View File
@@ -24,6 +24,8 @@
<true/>
<key>UILaunchStoryboardName</key>
<string>Launch</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
@@ -42,7 +44,5 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UIMainStoryboardFile</key>
<string>Main</string>
</dict>
</plist>
+2 -3
View File
@@ -1,13 +1,12 @@
Pod::Spec.new do |s|
s.name = 'RAMPaperSwitch'
s.version = '1.0.4'
s.version = '2.0.3'
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'
s.requires_arc = true
end
+4 -4
View File
@@ -6,10 +6,11 @@
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Ramotion/paper-switch)
[![Twitter](https://img.shields.io/badge/Twitter-@Ramotion-blue.svg?style=flat)](http://twitter.com/Ramotion)
[![Travis](https://img.shields.io/travis/Ramotion/paper-switch.svg)](https://travis-ci.org/Ramotion/paper-switch)
[![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)
@@ -22,14 +23,13 @@ The [iPhone mockup](https://store.ramotion.com/product/iphone-6-plus-mockups?utm
- iOS 8.0+
- Xcode 6.1
#Installation
Just add the `RAMPaperSwitch` folder to your project.
or use [CocoaPods](https://cocoapods.org) with Podfile:
``` ruby
pod 'RAMPaperSwitch'
pod 'RAMPaperSwitch', '~> 2.0.3'
```
or [Carthage](https://github.com/Carthage/Carthage) users can simply add to their `Cartfile`:
```