From eb1a968c1308ab89da26271f9ede386a68bad3f6 Mon Sep 17 00:00:00 2001 From: antonnazarov Date: Fri, 21 Sep 2018 20:37:04 +0300 Subject: [PATCH 1/3] [feature/swift4] Migrate to swift 4 --- Example/StarWarsAnimations.xcodeproj/project.pbxproj | 4 ++-- .../Controller/MainSettingsViewController.swift | 4 ++-- Example/StarWarsAnimations/View/StarsOverlay.swift | 2 +- StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift | 2 +- .../StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Example/StarWarsAnimations.xcodeproj/project.pbxproj b/Example/StarWarsAnimations.xcodeproj/project.pbxproj index bcfc927..03cb93e 100644 --- a/Example/StarWarsAnimations.xcodeproj/project.pbxproj +++ b/Example/StarWarsAnimations.xcodeproj/project.pbxproj @@ -569,7 +569,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -584,7 +584,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.Yalantis.StarWars; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.0; }; name = Release; }; diff --git a/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift b/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift index aef56d0..42bf1e3 100644 --- a/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift +++ b/Example/StarWarsAnimations/Controller/MainSettingsViewController.swift @@ -29,8 +29,8 @@ class MainSettingsViewController: UIViewController { navigationController!.navigationBar.shadowImage = UIImage() navigationController!.navigationBar.isTranslucent = true navigationController!.navigationBar.titleTextAttributes = [ - NSFontAttributeName: UIFont(name: "GothamPro", size: 20)!, - NSForegroundColorAttributeName: UIColor.white + NSAttributedStringKey.font: UIFont(name: "GothamPro", size: 20)!, + NSAttributedStringKey.foregroundColor: UIColor.white ] } diff --git a/Example/StarWarsAnimations/View/StarsOverlay.swift b/Example/StarWarsAnimations/View/StarsOverlay.swift index 8ccad6a..0950995 100644 --- a/Example/StarWarsAnimations/View/StarsOverlay.swift +++ b/Example/StarWarsAnimations/View/StarsOverlay.swift @@ -69,7 +69,7 @@ class StarsOverlay: UIView { } } - func randomizeEmitterPosition() { + @objc func randomizeEmitterPosition() { let sizeWidth = max(bounds.width, bounds.height) let radius = CGFloat(arc4random()).truncatingRemainder(dividingBy: sizeWidth) emitter.emitterSize = CGSize(width: radius, height: radius) diff --git a/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift b/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift index 9229b6a..f9deb4d 100644 --- a/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift +++ b/StarWars/StarWarsGLAnimator/StarWarsGLAnimator.swift @@ -91,7 +91,7 @@ open class StarWarsGLAnimator: NSObject, UIViewControllerAnimatedTransitioning { displayLink = nil } - func displayLinkTick(_ displayLink: CADisplayLink) { + @objc func displayLinkTick(_ displayLink: CADisplayLink) { if let lastUpdateTime = lastUpdateTime { let timeSinceLastUpdate = Date.timeIntervalSinceReferenceDate - lastUpdateTime self.lastUpdateTime = Date.timeIntervalSinceReferenceDate diff --git a/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift b/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift index 3b1586d..e39340b 100644 --- a/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift +++ b/StarWars/StarWarsUIDynamicAnimator/StarWarsUIDynamicAnimator.swift @@ -72,7 +72,7 @@ open class StarWarsUIDynamicAnimator: NSObject, UIViewControllerAnimatedTransiti self.transitionContext = transitionContext } - func completeTransition() { + @objc func completeTransition() { transitionContext.completeTransition(!transitionContext.transitionWasCancelled) } } From c287cb299c668bca2dae9499c47902f57646712c Mon Sep 17 00:00:00 2001 From: Roman Kyrylenko Date: Tue, 16 Oct 2018 13:04:12 +0300 Subject: [PATCH 2/3] [Update] podspec, readme --- LICENSE | 3 +-- README.md | 48 +++++++++++++++++++++++++++--------------------- StarWars.podspec | 2 +- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/LICENSE b/LICENSE index f10f992..cd9253f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2017 Yalantis +Copyright (c) 2018 Yalantis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/README.md b/README.md index 621ac14..6d1ff13 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Also, read how it was done in [our blog](https://yalantis.com/blog/uidynamics-ui - iOS 8.0+ - Xcode 8 -- Swift 3 +- Swift 4 ## Installing with [CocoaPods](https://cocoapods.org) @@ -36,12 +36,12 @@ Then just implement class of *UIViewControllerTransitioningDelegate* that will r ```swift override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { - let destination = segue.destinationViewController - destination.transitioningDelegate = self +let destination = segue.destinationViewController +destination.transitioningDelegate = self } func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { - return StarWarsGLAnimator() +return StarWarsGLAnimator() } ``` @@ -62,27 +62,33 @@ We’d be really happy if you sent us links to your projects where you use our c P.S. We’re going to publish more awesomeness wrapped in code and a tutorial on how to make UI for iOS (Android) better than better. Stay tuned! +## Version history + +- `1.0` Swift 2.0 +- `2.0` Adds Swift 3.0 support +- `3.0` Adds Swift 4.0 support + ## License - The MIT License (MIT) +The MIT License (MIT) - Copyright © 2017 Yalantis +Copyright © 2018 Yalantis - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/StarWars.podspec b/StarWars.podspec index 3f0cd23..2db313e 100644 --- a/StarWars.podspec +++ b/StarWars.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = "StarWars" - s.version = "2.0" + s.version = "3.0" s.summary = "This component implements transition animation to crumble view-controller into tiny pieces" s.homepage = "https://yalantis.com/blog/uidynamics-uikit-or-opengl-3-types-of-ios-animations-for-the-star-wars/" From 229228b97c9b8d5551eae69b66f474cf1134ffe2 Mon Sep 17 00:00:00 2001 From: Roman Kyrylenko Date: Tue, 16 Oct 2018 13:09:20 +0300 Subject: [PATCH 3/3] [Fix] warning --- .../project.pbxproj | 22 +++++++++---------- .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++++ .../AppIcon.appiconset/Contents.json | 5 +++++ .../Extension/UIColor+String.swift | 2 +- 4 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 Example/StarWarsAnimations.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/Example/StarWarsAnimations.xcodeproj/project.pbxproj b/Example/StarWarsAnimations.xcodeproj/project.pbxproj index 03cb93e..8f8b972 100644 --- a/Example/StarWarsAnimations.xcodeproj/project.pbxproj +++ b/Example/StarWarsAnimations.xcodeproj/project.pbxproj @@ -120,11 +120,11 @@ 2A89D8961BD6633300A2C503 /* StarWars */ = { isa = PBXGroup; children = ( + 2A89D8991BD6633300A2C503 /* Info.plist */, + 2A89D8971BD6633300A2C503 /* StarWars.h */, 2A89D8A21BD6639700A2C503 /* StarWarsGLAnimator */, - 2A89D8B01BD663BD00A2C503 /* StarWarsUIViewAnimator */, 2A89D8AD1BD663A600A2C503 /* StarWarsUIDynamicAnimator */, - 2A89D8971BD6633300A2C503 /* StarWars.h */, - 2A89D8991BD6633300A2C503 /* Info.plist */, + 2A89D8B01BD663BD00A2C503 /* StarWarsUIViewAnimator */, ); path = StarWars; sourceTree = ""; @@ -232,17 +232,17 @@ 2ACECE391BA2BF2E005689AD /* StarWarsDemo */ = { isa = PBXGroup; children = ( + 2ACECE411BA2BF2E005689AD /* Assets.xcassets */, + 2A977C981BC55CB20038BE80 /* Circular Animation */, 2A977CAB1BC55CE60038BE80 /* Controller */, - 2A977CBB1BC55D380038BE80 /* ViewModel */, - 2A977CBA1BC55D1C0038BE80 /* View */, - 2A977CB71BC55D0F0038BE80 /* Misc */, 2A977CB01BC55CFA0038BE80 /* Extension */, - 2A977C981BC55CB20038BE80 /* Circular Animation */, - 2A6955691BB584EF009AB18A /* Resources */, - 2ACECE3E1BA2BF2E005689AD /* Main.storyboard */, - 2ACECE411BA2BF2E005689AD /* Assets.xcassets */, - 2ACECE431BA2BF2E005689AD /* LaunchScreen.storyboard */, 2ACECE461BA2BF2E005689AD /* Info.plist */, + 2ACECE431BA2BF2E005689AD /* LaunchScreen.storyboard */, + 2ACECE3E1BA2BF2E005689AD /* Main.storyboard */, + 2A977CB71BC55D0F0038BE80 /* Misc */, + 2A6955691BB584EF009AB18A /* Resources */, + 2A977CBA1BC55D1C0038BE80 /* View */, + 2A977CBB1BC55D380038BE80 /* ViewModel */, ); name = StarWarsDemo; path = StarWarsAnimations; diff --git a/Example/StarWarsAnimations.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/StarWarsAnimations.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/StarWarsAnimations.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/StarWarsAnimations/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example/StarWarsAnimations/Assets.xcassets/AppIcon.appiconset/Contents.json index 78eb270..8f98d3f 100644 --- a/Example/StarWarsAnimations/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/StarWarsAnimations/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -45,6 +45,11 @@ "idiom" : "iphone", "filename" : "Icon-60@3x.png", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/Example/StarWarsAnimations/Extension/UIColor+String.swift b/Example/StarWarsAnimations/Extension/UIColor+String.swift index 4a2bdf7..7d58aed 100644 --- a/Example/StarWarsAnimations/Extension/UIColor+String.swift +++ b/Example/StarWarsAnimations/Extension/UIColor+String.swift @@ -15,7 +15,7 @@ extension UIColor { var int = UInt32() Scanner(string: hex).scanHexInt32(&int) let a, r, g, b: UInt32 - switch hex.characters.count { + switch hex.count { case 3: // RGB (12-bit) (a, r, g, b) = (255, (int >> 8) * 17, (int >> 4 & 0xF) * 17, (int & 0xF) * 17) case 6: // RGB (24-bit)