Skip to content

Commit

Permalink
support swift 4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
TBXark committed Sep 23, 2017
1 parent fbdbb18 commit f107bb4
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 18 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
[![Swift Version][swift-image]][swift-url]
[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/TBXark/TKSwitcherCollection/master/LICENSE)
[![CocoaPods](http://img.shields.io/cocoapods/v/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q= TKSwitcherCollection)
[![CocoaPods](http://img.shields.io/cocoapods/p/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q= TKSwitcherCollection)
[![CocoaPods](http://img.shields.io/cocoapods/v/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q=TKSwitcherCollection)
[![CocoaPods](http://img.shields.io/cocoapods/p/TKSwitcherCollection.svg?style=flat)](http://cocoapods.org/?q=TKSwitcherCollection)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Support](https://img.shields.io/badge/support-iOS%208%2B%20-blue.svg?style=flat)](https://www.apple.com/nl/ios/)


## Requirements

- iOS 8.0+
- Xcode 8.0
- Swift 3.0
- Xcode 9.0
- Swift 4.0

## Installation

Expand All @@ -39,7 +39,7 @@ Create a `Cartfile` that lists the framework and run `carthage update`. Follow t
github "tbxark/TKSwitcherCollection"
```
#### Manually
1. Download and drop ```SwitchCollection/Classes``` in your project.
1. Download and drop ```TKSwitcherCollection``` in your project.
2. Congratulations!

## Usage example
Expand All @@ -54,6 +54,8 @@ github "tbxark/TKSwitcherCollection"


## Release History
* 1.4.0
support swift 4.0
* 1.3.1
support swift 3.0
* 1.0.3
Expand Down
30 changes: 23 additions & 7 deletions SwitcherCollection.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,18 @@
attributes = {
CLASSPREFIX = TK;
LastSwiftUpdateCheck = 0710;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = TBXark;
TargetAttributes = {
6A555E961BDCA58700FC36E6 = {
CreatedOnToolsVersion = 7.1;
DevelopmentTeam = 858CBVXSWP;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
6A9104111D53A8740009451B = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 858CBVXSWP;
LastSwiftMigration = 0820;
LastSwiftMigration = 0900;
};
};
};
Expand Down Expand Up @@ -305,14 +305,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -351,14 +357,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -394,7 +406,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.SwitcherCollection;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -409,7 +422,8 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.SwitcherCollection;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -433,7 +447,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -459,7 +474,8 @@
PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.TKSwitcherCollection;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = On;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -45,6 +46,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion SwitcherCollection/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ViewController: UIViewController {
super.viewDidLoad()
}

func animateSwitch(_ timer:Timer){
@objc func animateSwitch(_ timer:Timer){
let switcher = switchArray[count]
switcher.setOn(switcher.isOn, animate: true)
count += 1
Expand Down
2 changes: 1 addition & 1 deletion TKSwitcherCollection/TKBaseSwitcher.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ open class TKBaseSwitch: UIControl {
self.addGestureRecognizer(tap)
}

internal func changeValue(){
@objc internal func changeValue(){
on = !on
valueChange?(!isOn)
sendActions(for: UIControlEvents.valueChanged);
Expand Down
2 changes: 1 addition & 1 deletion TKSwitcherCollection/TKSimpleSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ open class TKSimpleSwitch: TKBaseSwitch {
// 旋转动画
if rotateWhenValueChange{
UIView.animate(withDuration: duration, animations: { () -> Void in
self.transform = self.transform.rotated(by: CGFloat(M_PI))
self.transform = self.transform.rotated(by: CGFloat.pi)
})
}

Expand Down
2 changes: 1 addition & 1 deletion TKSwitcherCollection/TKSmileSwitch.swift
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ private class TKSmileFaceView : UIView {

func rotation(_ duration:Double,count:Int,clockwise:Bool){
let rotationTransformAnim = CAKeyframeAnimation(keyPath:"transform.rotation.z")
rotationTransformAnim.values = [0,180 * CGFloat(M_PI/180) * CGFloat(count) * (clockwise ? 1 : -1)]
rotationTransformAnim.values = [0,180 * CGFloat.pi/180 * CGFloat(count) * (clockwise ? 1 : -1)]
rotationTransformAnim.keyTimes = [0, 1]
rotationTransformAnim.isRemovedOnCompletion = false
rotationTransformAnim.duration = duration
Expand Down

0 comments on commit f107bb4

Please sign in to comment.