diff --git a/README.md b/README.md index 032cc1e..8742566 100755 --- a/README.md +++ b/README.md @@ -3,8 +3,8 @@ [![Swift Version][swift-image]][swift-url] [![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/TBXark/TKRubberIndicator/master/LICENSE) -[![CocoaPods](http://img.shields.io/cocoapods/v/TKRubberPageControl.svg?style=flat)](http://cocoapods.org/?q= TKRubberPageControl) -[![CocoaPods](http://img.shields.io/cocoapods/p/TKRubberPageControl.svg?style=flat)](http://cocoapods.org/?q= TKRubberPageControl) +[![CocoaPods](http://img.shields.io/cocoapods/v/TKRubberPageControl.svg?style=flat)](http://cocoapods.org/?q=TKRubberPageControl) +[![CocoaPods](http://img.shields.io/cocoapods/p/TKRubberPageControl.svg?style=flat)](http://cocoapods.org/?q=TKRubberPageControl) [![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/) @@ -13,9 +13,9 @@ ## Requirements -- Swift 3.0 +- Swift 4.0 - iOS 8.0+ -- Xcode 8.0 +- Xcode 9.0 ## Installation @@ -38,7 +38,7 @@ import TKRubberPageControl Create a `Cartfile` that lists the framework and run `carthage update`. Follow the [instructions](https://github.com/Carthage/Carthage#if-youre-building-for-ios) to add `$(SRCROOT)/Carthage/Build/iOS/TKRubberPageControl.framework` to an iOS project. ``` -github "tbxark/TKRubberPageControl" +github "tbxark/TKRubberIndicator" ``` #### Manually 1. Download and drop ```TKRubberPageControl.swift``` in your project. @@ -98,6 +98,9 @@ class ViewController: UIViewController { ## Release History +* 1.4.0 + Swift 4.0 + * 1.3.1 Bug Fixed diff --git a/TKRubberIndicator.xcodeproj/project.pbxproj b/TKRubberIndicator.xcodeproj/project.pbxproj index b8d215c..a3426ef 100755 --- a/TKRubberIndicator.xcodeproj/project.pbxproj +++ b/TKRubberIndicator.xcodeproj/project.pbxproj @@ -184,12 +184,12 @@ 6A555EC51BDE277B00FC36E6 = { CreatedOnToolsVersion = 7.1; DevelopmentTeam = 858CBVXSWP; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 6A9103F51D539B370009451B = { CreatedOnToolsVersion = 7.3.1; DevelopmentTeam = 858CBVXSWP; - LastSwiftMigration = 0820; + LastSwiftMigration = 0900; }; }; }; @@ -372,7 +372,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.TKRubberIndicator; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -386,7 +387,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.TKRubberIndicator; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = On; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -409,7 +411,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 = ""; @@ -434,7 +437,8 @@ PRODUCT_BUNDLE_IDENTIFIER = com.TBXark.TKRubberPageControl; 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 = ""; diff --git a/TKRubberIndicator.xcodeproj/project.xcworkspace/xcuserdata/Tbxark.xcuserdatad/UserInterfaceState.xcuserstate b/TKRubberIndicator.xcodeproj/project.xcworkspace/xcuserdata/Tbxark.xcuserdatad/UserInterfaceState.xcuserstate index cf3ccf9..b60ed69 100755 Binary files a/TKRubberIndicator.xcodeproj/project.xcworkspace/xcuserdata/Tbxark.xcuserdatad/UserInterfaceState.xcuserstate and b/TKRubberIndicator.xcodeproj/project.xcworkspace/xcuserdata/Tbxark.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/TKRubberIndicator.xcodeproj/xcuserdata/Tbxark.xcuserdatad/xcschemes/TKRubberIndicator.xcscheme b/TKRubberIndicator.xcodeproj/xcuserdata/Tbxark.xcuserdatad/xcschemes/TKRubberIndicator.xcscheme index d20a99e..96ab6c7 100755 --- a/TKRubberIndicator.xcodeproj/xcuserdata/Tbxark.xcuserdatad/xcschemes/TKRubberIndicator.xcscheme +++ b/TKRubberIndicator.xcodeproj/xcuserdata/Tbxark.xcuserdatad/xcschemes/TKRubberIndicator.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" shouldUseLaunchSchemeArgsEnv = "YES"> @@ -45,6 +46,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/TKRubberIndicator/ViewController.swift b/TKRubberIndicator/ViewController.swift index 0298bd2..490a249 100755 --- a/TKRubberIndicator/ViewController.swift +++ b/TKRubberIndicator/ViewController.swift @@ -32,7 +32,7 @@ class ViewController: UIViewController { @IBAction func pageCountChange(_ sender: UISegmentedControl) { page.numberOfpage = sender.selectedSegmentIndex + 3 } - func targetActionValueChange(_ page:TKRubberPageControl){ + @objc func targetActionValueChange(_ page:TKRubberPageControl){ print("Target-Action : Page is \(page.currentIndex)") } diff --git a/TKRubberPageControl/TKRubberPageControl.swift b/TKRubberPageControl/TKRubberPageControl.swift index 60235dd..179bb1e 100755 --- a/TKRubberPageControl/TKRubberPageControl.swift +++ b/TKRubberPageControl/TKRubberPageControl.swift @@ -14,7 +14,7 @@ import UIKit private enum TKMoveDirection{ case left case right - func toBool() -> Bool{ + func toLeft() -> Bool{ switch self{ case .left: return true @@ -88,21 +88,21 @@ open class TKRubberPageControl : UIControl { } // 手势 - fileprivate var indexTap : UITapGestureRecognizer? + private var indexTap : UITapGestureRecognizer? // 所有图层 - fileprivate var smallBubbles = [TKBubbleCell]() - fileprivate var backgroundLayer = CAShapeLayer() - fileprivate var mainBubble = CAShapeLayer() - fileprivate var backLineLayer = CAShapeLayer() + private var smallBubbles = [TKBubbleCell]() + private var backgroundLayer = CAShapeLayer() + private var mainBubble = CAShapeLayer() + private var backLineLayer = CAShapeLayer() // 大球缩放比例 - fileprivate let bubbleScale : CGFloat = 1/3.0 + private let bubbleScale : CGFloat = 1/3.0 // 存储计算用的 - fileprivate var xPointbegin : CGFloat = 0 - fileprivate var xPointEnd : CGFloat = 0 - fileprivate var yPointbegin : CGFloat = 0 - fileprivate var yPointEnd : CGFloat = 0 + private var xPointbegin : CGFloat = 0 + private var xPointEnd : CGFloat = 0 + private var yPointbegin : CGFloat = 0 + private var yPointEnd : CGFloat = 0 public init(frame: CGRect, count: Int, config: TKRubberPageControlConfig = TKRubberPageControlConfig()) { @@ -118,7 +118,7 @@ open class TKRubberPageControl : UIControl { setUpView() } - fileprivate func setUpView(){ + private func setUpView(){ // 一些奇怪的位置计算 @@ -202,7 +202,7 @@ open class TKRubberPageControl : UIControl { // 手势事件 - @objc fileprivate func tapValueChange(_ ges: UITapGestureRecognizer){ + @objc private func tapValueChange(_ ges: UITapGestureRecognizer){ let point = ges.location(in: self) if point.y > yPointbegin && point.y < yPointEnd && point.x > xPointbegin && point.x < xPointEnd{ let index = Int(point.x - xPointbegin) / Int(styleConfig.smallBubbleMoveRadius) @@ -211,7 +211,7 @@ open class TKRubberPageControl : UIControl { } // Index值变化 - fileprivate func changIndexToValue(_ valueIndex: Int){ + private func changIndexToValue(_ valueIndex: Int){ var index = valueIndex if index >= numberOfpage { index = numberOfpage - 1 } if index < 0 { index = 0 } @@ -222,7 +222,7 @@ open class TKRubberPageControl : UIControl { // 小球动画 for index in range{ - let smallBubbleIndex = (direction.toBool()) ? (index - 1) : (index) + let smallBubbleIndex = (direction.toLeft()) ? (index - 1) : (index) let smallBubble = smallBubbles[smallBubbleIndex] smallBubble.positionChange(direction, radius: styleConfig.smallBubbleMoveRadius / 2, @@ -268,11 +268,11 @@ open class TKRubberPageControl : UIControl { // MARK: - Small Bubble private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate { - fileprivate var bubbleLayer = CAShapeLayer() - fileprivate let bubbleScale : CGFloat = 0.5 - fileprivate var lastDirection : TKMoveDirection! - fileprivate var styleConfig : TKRubberPageControlConfig - fileprivate var cachePosition = CGPoint.zero + var bubbleLayer = CAShapeLayer() + let bubbleScale : CGFloat = 0.5 + var lastDirection : TKMoveDirection! + var styleConfig : TKRubberPageControlConfig + var cachePosition = CGPoint.zero override init(layer: Any) { styleConfig = TKRubberPageControlConfig() @@ -293,7 +293,7 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate { setupLayer() } - fileprivate func setupLayer(){ + private func setupLayer(){ frame = CGRect(x: 0, y: 0, width: styleConfig.smallBubbleSize, height: styleConfig.smallBubbleSize) bubbleLayer.path = UIBezierPath(ovalIn: bounds).cgPath @@ -305,13 +305,13 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate { } // beginTime 本来是留给小球轮播用的, 但是效果不好就没用了 - internal func positionChange(_ direction: TKMoveDirection, radius: CGFloat, duration: CFTimeInterval, beginTime: CFTimeInterval){ + func positionChange(_ direction: TKMoveDirection, radius: CGFloat, duration: CFTimeInterval, beginTime: CFTimeInterval){ - let toLeft = direction.toBool() + let toLeft = direction.toLeft() let movePath = UIBezierPath() var center = CGPoint.zero - let startAngle = toLeft ? 0 : CGFloat(M_PI) - let endAngle = toLeft ? CGFloat(M_PI) : 0 + let startAngle = toLeft ? 0 : CGFloat.pi + let endAngle = toLeft ? CGFloat.pi : 0 center.x += radius * (toLeft ? -1 : 1) lastDirection = direction @@ -368,7 +368,7 @@ private class TKBubbleCell: CAShapeLayer, CAAnimationDelegate { CATransaction.setAnimationDuration(0) CATransaction.setDisableActions(true) var point = cachePosition - point.x += (styleConfig.smallBubbleSize + styleConfig.bubbleXOffsetSpace) * CGFloat(lastDirection.toBool() ? -1 : 1) + point.x += (styleConfig.smallBubbleSize + styleConfig.bubbleXOffsetSpace) * CGFloat(lastDirection.toLeft() ? -1 : 1) position = point opacity = 1 CATransaction.commit()