From 55b3032abad970a72f4534c81f25ed040ad1cb53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Attila=20Sz=C3=A1sz?= Date: Tue, 22 Mar 2016 13:08:28 +0200 Subject: [PATCH 01/42] updated to swift 2.2 to remove warnings --- Spring/KeyboardLayoutConstraint.swift | 4 ++-- Spring/Misc.swift | 2 +- Spring/Spring.swift | 2 +- SpringApp/CodeViewController.swift | 4 ++-- .../AppIcon.appiconset/Contents.json | 6 ++++++ .../AppIcon.appiconset/appicon@167.png | Bin 0 -> 42272 bytes SpringApp/OptionsViewController.swift | 6 +++--- 7 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 SpringApp/Images.xcassets/AppIcon.appiconset/appicon@167.png diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 1fad0b5..c45532d 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -32,8 +32,8 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { offset = constant - NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillShowNotification:", name: UIKeyboardWillShowNotification, object: nil) - NSNotificationCenter.defaultCenter().addObserver(self, selector: "keyboardWillHideNotification:", name: UIKeyboardWillHideNotification, object: nil) + NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: UIKeyboardWillShowNotification, object: nil) + NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: UIKeyboardWillHideNotification, object: nil) } deinit { diff --git a/Spring/Misc.swift b/Spring/Misc.swift index a2aa327..532071d 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -142,7 +142,7 @@ public func randomStringWithLength (len : Int) -> NSString { let randomString : NSMutableString = NSMutableString(capacity: len) - for (var i=0; i < len; i++){ + for _ in 0 ..< len { let length = UInt32 (letters.length) let rand = arc4random_uniform(length) randomString.appendFormat("%C", letters.characterAtIndex(Int(rand))) diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 06c7bf7..0cd0d7a 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -65,7 +65,7 @@ public class Spring : NSObject { } func commonInit() { - NSNotificationCenter.defaultCenter().addObserver(self, selector: "didBecomeActiveNotification:", name: UIApplicationDidBecomeActiveNotification, object: nil) + NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: UIApplicationDidBecomeActiveNotification, object: nil) } func didBecomeActiveNotification(notification: NSNotification) { diff --git a/SpringApp/CodeViewController.swift b/SpringApp/CodeViewController.swift index 96e4895..3b01f45 100644 --- a/SpringApp/CodeViewController.swift +++ b/SpringApp/CodeViewController.swift @@ -58,7 +58,7 @@ class CodeViewController: UIViewController { } @IBAction func closeButtonPressed(sender: AnyObject) { - UIApplication.sharedApplication().sendAction("maximizeView:", to: nil, from: self, forEvent: nil) + UIApplication.sharedApplication().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, forEvent: nil) modalView.animation = "slideRight" modalView.animateFrom = false @@ -72,6 +72,6 @@ class CodeViewController: UIViewController { modalView.animate() - UIApplication.sharedApplication().sendAction("minimizeView:", to: nil, from: self, forEvent: nil) + UIApplication.sharedApplication().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, forEvent: nil) } } diff --git a/SpringApp/Images.xcassets/AppIcon.appiconset/Contents.json b/SpringApp/Images.xcassets/AppIcon.appiconset/Contents.json index 17d5afa..1acc2b0 100644 --- a/SpringApp/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/SpringApp/Images.xcassets/AppIcon.appiconset/Contents.json @@ -71,6 +71,12 @@ "idiom" : "ipad", "filename" : "appicon@152.png", "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "appicon@167.png", + "scale" : "2x" } ], "info" : { diff --git a/SpringApp/Images.xcassets/AppIcon.appiconset/appicon@167.png b/SpringApp/Images.xcassets/AppIcon.appiconset/appicon@167.png new file mode 100644 index 0000000000000000000000000000000000000000..9ae244410e17e6a1094ef419aff46e4abb02f660 GIT binary patch literal 42272 zcmeF3b#Pp}(%{F;F*8HV%*@Qp%*@P8NsMs}F*DmSGseu!6tf*O#<Xy!w&qT<}ioro+K?48)I00sy!#rYV^zEA6B4 z+^k*-N`?D>l(JJqg(OfEeCLl6OG-%yg&-MDn6-ea(1|D_0*c+A84eN^<^LX4ff_av zdLCknFgq$JCp>cSe#0xrYPRKOXXL4Nj(4~8BCUE1q5~54lQ@$Ci$83UARgj+P~X?y zjV)UK0B90>00LySF`?5VF%aO^mz$f4r~{%60OURe0}1Gm`P@N|6ZQ;$AegKT_+hMuwXJc^ZH|ncvP7z(4Ia*$W7u^^p)2 zC^Hs7fNT;j3^3;cl#Z!JiU8E<0Vt+YUpWBtGyr-DHB)gwWj&x{6al6R00|4AR|pTG z0DyV{^!tg4-2uVL02I-4HSRO2a)e#V7gEVp+>In0A^}>EG!77IYP5LdqY~&;D69s+ z1}XfsT^`Api~-E>>lecSKxQoJ%V;ki-ACV)kB+iN)xFW9IcNueCNebKeA*r>vF8T> zHk^GYo~Y@nvHZEf{cWDI-yVaS>%wHZ+`Kcbg6FRVWbQAjUD*F*Ba#)Xay(3P=u7!YS`B81slC1mh@r-cCLne_Nxz2jN{~0aRM@0(r&K6zUj( zTuYH5s5^Ijy8!^so9#NM$ss}f&4V_^+@4SP9>p@>0{l%S;v4_~U11Vh<-uycK1cvS zI5U8cmly=*c0sgq`A`Nbg7p z2EtJkh@@g!#2FMLl?hbDanE@ifjPpoMVn%|`T>lA51}n$3?Bok6nLg#YlRvM*|35| zvth=Kof%T1(K0`eJJw+Fyl2hY9WOD5UySAz>Z9-2!+>D=YE4hu+b#Hoof<0MXy^-3 zDQrnER;6kwNOQ!M(byL^P^18n4k%VoH$egeJOOcaX?59o@j?O|5@y6jC^jgNV1+I+ zqWD6o8qy}jA73#H85zRV#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42] Remove the redudant word in readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a0502c5..38d4a6a 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ In Identity Inspector, connect the UIView to SpringView Class and set the animat ## Autostart -Allows you to animate without code. Don't need to use this is if you plan to start the animation in code. +Allows you to animate without code. Don't need to use this if you plan to start the animation in code. ## Autohide Saves you the hassle of adding a line "layer.alpha = 0" in viewDidLoad(). From 16af531b19fb7449983ee0a3cb65f490920b32ba Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Wed, 22 Jun 2016 14:12:49 -0500 Subject: [PATCH 03/42] added missing parameter name --- Spring/SpringImageView.swift | 6 +++--- SpringApp.xcodeproj/project.pbxproj | 8 +++++++- .../xcshareddata/xcschemes/Spring.xcscheme | 10 +++++----- .../xcshareddata/xcschemes/SpringApp.xcscheme | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/Spring/SpringImageView.swift b/Spring/SpringImageView.swift index 1ba3904..8cd9ab2 100644 --- a/Spring/SpringImageView.swift +++ b/Spring/SpringImageView.swift @@ -58,7 +58,7 @@ public class SpringImageView: UIImageView, Springable { } public func animateNext(completion: () -> ()) { - self.spring.animateNext(completion) + self.spring.animateNext(completion: completion) } public func animateTo() { @@ -66,7 +66,7 @@ public class SpringImageView: UIImageView, Springable { } public func animateToNext(completion: () -> ()) { - self.spring.animateToNext(completion) + self.spring.animateToNext(completion: completion) } -} \ No newline at end of file +} diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index 8ac99e0..5259b24 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -408,7 +408,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Meng To"; TargetAttributes = { 1A4FDA321A6E44780099D309 = { @@ -631,6 +631,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -661,6 +662,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; @@ -688,6 +690,7 @@ ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -730,6 +733,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; GCC_WARN_UNDECLARED_SELECTOR = YES; @@ -765,6 +769,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -793,6 +798,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; diff --git a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme index 8066cbf..3748fca 100644 --- a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme +++ b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> Date: Wed, 22 Jun 2016 14:49:43 -0500 Subject: [PATCH 04/42] swift 3.0 convert --- Spring/AsyncButton.swift | 6 +- Spring/AsyncImageView.swift | 4 +- Spring/AutoTextView.swift | 4 +- Spring/BlurView.swift | 6 +- Spring/DesignableButton.swift | 8 +- Spring/DesignableImageView.swift | 4 +- Spring/DesignableTabBarController.swift | 38 +++++----- Spring/DesignableTextField.swift | 16 ++-- Spring/DesignableTextView.swift | 4 +- Spring/DesignableView.swift | 10 +-- Spring/ImageLoader.swift | 12 +-- Spring/KeyboardLayoutConstraint.swift | 24 +++--- Spring/LoadingView.swift | 15 ++-- Spring/Misc.swift | 57 +++++++------- Spring/SoundPlayer.swift | 4 +- Spring/Spring.swift | 98 ++++++++++++------------- Spring/SpringAnimation.swift | 50 ++++++------- Spring/SpringTextField.swift | 6 +- Spring/SpringTextView.swift | 6 +- Spring/SpringView.swift | 6 +- Spring/TransitionManager.swift | 26 +++---- Spring/TransitionZoom.swift | 30 ++++---- SpringApp.xcodeproj/project.pbxproj | 12 +++ SpringApp/AppDelegate.swift | 12 +-- SpringApp/CodeViewController.swift | 10 +-- SpringApp/OptionsViewController.swift | 58 +++++++-------- SpringApp/SpringViewController.swift | 66 ++++++++--------- SpringAppTests/SpringAppTests.swift | 2 +- SpringTests/SpringTests.swift | 2 +- 29 files changed, 306 insertions(+), 290 deletions(-) diff --git a/Spring/AsyncButton.swift b/Spring/AsyncButton.swift index d92937c..2c2804f 100644 --- a/Spring/AsyncButton.swift +++ b/Spring/AsyncButton.swift @@ -34,12 +34,12 @@ public class AsyncButton: UIButton { placeholderImage[state.rawValue] = placeholder if let urlString = url?.absoluteString { - ImageLoader.sharedLoader.imageForUrl(urlString) { [weak self] image, url in + ImageLoader.sharedLoader.imageForUrl(urlString: urlString) { [weak self] image, url in if let strongSelf = self { - dispatch_async(dispatch_get_main_queue(), { () -> Void in + DispatchQueue.main().asynchronously(execute: { () -> Void in if strongSelf.imageURL[state.rawValue]?.absoluteString == url { - strongSelf.setImage(image, forState: state) + strongSelf.setImage(image, for: state) } }) } diff --git a/Spring/AsyncImageView.swift b/Spring/AsyncImageView.swift index f3ac178..1f88a52 100644 --- a/Spring/AsyncImageView.swift +++ b/Spring/AsyncImageView.swift @@ -30,9 +30,9 @@ public class AsyncImageView: UIImageView { didSet { self.image = placeholderImage if let urlString = url?.absoluteString { - ImageLoader.sharedLoader.imageForUrl(urlString) { [weak self] image, url in + ImageLoader.sharedLoader.imageForUrl(urlString: urlString) { [weak self] image, url in if let strongSelf = self { - dispatch_async(dispatch_get_main_queue(), { () -> Void in + DispatchQueue.main().asynchronously(execute: { () -> Void in if strongSelf.url?.absoluteString == url { strongSelf.image = image ?? strongSelf.placeholderImage } diff --git a/Spring/AutoTextView.swift b/Spring/AutoTextView.swift index 3abced4..632f365 100644 --- a/Spring/AutoTextView.swift +++ b/Spring/AutoTextView.swift @@ -10,7 +10,7 @@ import UIKit public class AutoTextView: UITextView { override public func intrinsicContentSize() -> CGSize { - var size = self.sizeThatFits(CGSizeMake(self.frame.size.width, CGFloat.max)) + var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude)) size.width = self.frame.size.width if text.length == 0 { size.height = 0 @@ -21,4 +21,4 @@ public class AutoTextView: UITextView { return size } -} \ No newline at end of file +} diff --git a/Spring/BlurView.swift b/Spring/BlurView.swift index d7871ee..198d466 100644 --- a/Spring/BlurView.swift +++ b/Spring/BlurView.swift @@ -23,11 +23,11 @@ import UIKit public func insertBlurView (view: UIView, style: UIBlurEffectStyle) -> UIVisualEffectView { - view.backgroundColor = UIColor.clearColor() + view.backgroundColor = UIColor.clear() let blurEffect = UIBlurEffect(style: style) let blurEffectView = UIVisualEffectView(effect: blurEffect) blurEffectView.frame = view.bounds - view.insertSubview(blurEffectView, atIndex: 0) + view.insertSubview(blurEffectView, at: 0) return blurEffectView -} \ No newline at end of file +} diff --git a/Spring/DesignableButton.swift b/Spring/DesignableButton.swift index 5b0a9c7..237e8a5 100644 --- a/Spring/DesignableButton.swift +++ b/Spring/DesignableButton.swift @@ -24,9 +24,9 @@ import UIKit @IBDesignable public class DesignableButton: SpringButton { - @IBInspectable public var borderColor: UIColor = UIColor.clearColor() { + @IBInspectable public var borderColor: UIColor = UIColor.clear() { didSet { - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor } } @@ -42,9 +42,9 @@ import UIKit } } - @IBInspectable public var shadowColor: UIColor = UIColor.clearColor() { + @IBInspectable public var shadowColor: UIColor = UIColor.clear() { didSet { - layer.shadowColor = shadowColor.CGColor + layer.shadowColor = shadowColor.cgColor } } diff --git a/Spring/DesignableImageView.swift b/Spring/DesignableImageView.swift index 60c5a16..93b0992 100644 --- a/Spring/DesignableImageView.swift +++ b/Spring/DesignableImageView.swift @@ -24,9 +24,9 @@ import UIKit @IBDesignable public class DesignableImageView: SpringImageView { - @IBInspectable public var borderColor: UIColor = UIColor.clearColor() { + @IBInspectable public var borderColor: UIColor = UIColor.clear() { didSet { - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor } } diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index 16e9887..ff3a3c9 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -24,23 +24,23 @@ import UIKit @IBDesignable class DesignableTabBarController: UITabBarController { - @IBInspectable var normalTint: UIColor = UIColor.clearColor() { + @IBInspectable var normalTint: UIColor = UIColor.clear() { didSet { UITabBar.appearance().tintColor = normalTint - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], forState: UIControlState.Normal) + UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], for: UIControlState.normal) } } - @IBInspectable var selectedTint: UIColor = UIColor.clearColor() { + @IBInspectable var selectedTint: UIColor = UIColor.clear() { didSet { UITabBar.appearance().tintColor = selectedTint - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: selectedTint], forState:UIControlState.Selected) + UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: selectedTint], for:UIControlState.selected) } } @IBInspectable var fontName: String = "" { didSet { - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint, NSFontAttributeName: UIFont(name: fontName, size: 11)!], forState: UIControlState.Normal) + UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint, NSFontAttributeName: UIFont(name: fontName, size: 11)!], for: UIControlState.normal) } } @@ -48,7 +48,7 @@ import UIKit didSet { if let image = firstSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems[0].selectedImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) + tabBarItems?[0].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } } @@ -57,7 +57,7 @@ import UIKit didSet { if let image = secondSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems[1].selectedImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) + tabBarItems?[1].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } } @@ -66,7 +66,7 @@ import UIKit didSet { if let image = thirdSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems[2].selectedImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) + tabBarItems?[2].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } } @@ -75,7 +75,7 @@ import UIKit didSet { if let image = fourthSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems[3].selectedImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) + tabBarItems?[3].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } } @@ -84,7 +84,7 @@ import UIKit didSet { if let image = fifthSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems[4].selectedImage = image.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) + tabBarItems?[4].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) } } } @@ -94,7 +94,7 @@ import UIKit for item in self.tabBar.items as [UITabBarItem]! { if let image = item.image { - item.image = image.imageWithColor(self.normalTint).imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal) + item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImageRenderingMode.alwaysOriginal) } } } @@ -105,18 +105,18 @@ extension UIImage { UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale) let context = UIGraphicsGetCurrentContext() - CGContextTranslateCTM(context, 0, self.size.height) - CGContextScaleCTM(context, 1.0, -1.0); - CGContextSetBlendMode(context, CGBlendMode.Normal) + context!.translate(x: 0, y: self.size.height) + context!.scale(x: 1.0, y: -1.0); + context!.setBlendMode(CGBlendMode.normal) - let rect = CGRectMake(0, 0, self.size.width, self.size.height) as CGRect - CGContextClipToMask(context, rect, self.CGImage) + let rect = CGRect(0, 0, self.size.width, self.size.height) + CGContextClipToMask(context!, rect, self.cgImage!) tintColor.setFill() - CGContextFillRect(context, rect) + CGContextFillRect(context!, rect) - let newImage = UIGraphicsGetImageFromCurrentImageContext() as UIImage + let newImage = UIGraphicsGetImageFromCurrentImageContext()! as UIImage UIGraphicsEndImageContext() return newImage } -} \ No newline at end of file +} diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index 2a60b53..b19c0a3 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -24,9 +24,9 @@ import UIKit @IBDesignable public class DesignableTextField: SpringTextField { - @IBInspectable public var placeholderColor: UIColor = UIColor.clearColor() { + @IBInspectable public var placeholderColor: UIColor = UIColor.clear() { didSet { - attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor]) + attributedPlaceholder = AttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor]) layoutSubviews() } @@ -36,10 +36,10 @@ import UIKit didSet { let padding = UIView(frame: CGRectMake(0, 0, sidePadding, sidePadding)) - leftViewMode = UITextFieldViewMode.Always + leftViewMode = UITextFieldViewMode.always leftView = padding - rightViewMode = UITextFieldViewMode.Always + rightViewMode = UITextFieldViewMode.always rightView = padding } } @@ -48,7 +48,7 @@ import UIKit didSet { let padding = UIView(frame: CGRectMake(0, 0, leftPadding, 0)) - leftViewMode = UITextFieldViewMode.Always + leftViewMode = UITextFieldViewMode.always leftView = padding } } @@ -57,14 +57,14 @@ import UIKit didSet { let padding = UIView(frame: CGRectMake(0, 0, rightPadding, 0)) - rightViewMode = UITextFieldViewMode.Always + rightViewMode = UITextFieldViewMode.always rightView = padding } } - @IBInspectable public var borderColor: UIColor = UIColor.clearColor() { + @IBInspectable public var borderColor: UIColor = UIColor.clear() { didSet { - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor } } diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index 27fe285..2c0e64e 100644 --- a/Spring/DesignableTextView.swift +++ b/Spring/DesignableTextView.swift @@ -24,9 +24,9 @@ import UIKit @IBDesignable public class DesignableTextView: SpringTextView { - @IBInspectable public var borderColor: UIColor = UIColor.clearColor() { + @IBInspectable public var borderColor: UIColor = UIColor.clear() { didSet { - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor } } diff --git a/Spring/DesignableView.swift b/Spring/DesignableView.swift index 62cca91..189f10d 100644 --- a/Spring/DesignableView.swift +++ b/Spring/DesignableView.swift @@ -24,9 +24,9 @@ import UIKit @IBDesignable public class DesignableView: SpringView { - @IBInspectable public var borderColor: UIColor = UIColor.clearColor() { + @IBInspectable public var borderColor: UIColor = UIColor.clear() { didSet { - layer.borderColor = borderColor.CGColor + layer.borderColor = borderColor.cgColor } } @@ -42,9 +42,9 @@ import UIKit } } - @IBInspectable public var shadowColor: UIColor = UIColor.clearColor() { + @IBInspectable public var shadowColor: UIColor = UIColor.clear() { didSet { - layer.shadowColor = shadowColor.CGColor + layer.shadowColor = shadowColor.cgColor } } @@ -65,4 +65,4 @@ import UIKit layer.shadowOffset.height = shadowOffsetY } } -} \ No newline at end of file +} diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index eacd05e..829700e 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -26,7 +26,7 @@ import Foundation public class ImageLoader { - var cache = NSCache() + var cache = Cache() public class var sharedLoader : ImageLoader { struct Static { @@ -36,18 +36,18 @@ public class ImageLoader { } public func imageForUrl(urlString: String, completionHandler:(image: UIImage?, url: String) -> ()) { - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), {()in + DispatchQueue.global(Int(UInt64(DispatchQueue.GlobalAttributes.qosBackground.rawValue)), 0).asynchronously(execute: {()in let data: NSData? = self.cache.objectForKey(urlString) as? NSData if let goodData = data { - let image = UIImage(data: goodData) - dispatch_async(dispatch_get_main_queue(), {() in + let image = UIImage(data: goodData as Data) + DispatchQueue.main().asynchronously(execute: {() in completionHandler(image: image, url: urlString) }) return } - let downloadTask: NSURLSessionDataTask = NSURLSession.sharedSession().dataTaskWithURL(NSURL(string: urlString)!, completionHandler: { (data, response, error) -> Void in + let downloadTask: URLSessionDataTask = URLSession.sharedSession().dataTaskWithURL(NSURL(string: urlString)! as URL, completionHandler: { (data, response, error) -> Void in if (error != nil) { completionHandler(image: nil, url: urlString) return @@ -67,4 +67,4 @@ public class ImageLoader { }) } -} \ No newline at end of file +} diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index c45532d..642a06e 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -32,12 +32,12 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { offset = constant - NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: UIKeyboardWillShowNotification, object: nil) - NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: UIKeyboardWillHideNotification, object: nil) + NotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: UIKeyboardWillShowNotification, object: nil) + NotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: UIKeyboardWillHideNotification, object: nil) } deinit { - NSNotificationCenter.defaultCenter().removeObserver(self) + NotificationCenter.default().removeObserver(self) } // MARK: Notification @@ -45,22 +45,22 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { func keyboardWillShowNotification(notification: NSNotification) { if let userInfo = notification.userInfo { if let frameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue { - let frame = frameValue.CGRectValue() + let frame = frameValue.cgRectValue() keyboardVisibleHeight = frame.size.height } self.updateConstant() switch (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber) { - case let (.Some(duration), .Some(curve)): + case let (.some(duration), .some(curve)): let options = UIViewAnimationOptions(rawValue: curve.unsignedLongValue) - UIView.animateWithDuration( - NSTimeInterval(duration.doubleValue), + UIView.animate( + withDuration: TimeInterval(duration.doubleValue), delay: 0, options: options, animations: { - UIApplication.sharedApplication().keyWindow?.layoutIfNeeded() + UIApplication.shared().keyWindow?.layoutIfNeeded() return }, completion: { finished in }) @@ -80,16 +80,16 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { if let userInfo = notification.userInfo { switch (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber) { - case let (.Some(duration), .Some(curve)): + case let (.some(duration), .some(curve)): let options = UIViewAnimationOptions(rawValue: curve.unsignedLongValue) - UIView.animateWithDuration( - NSTimeInterval(duration.doubleValue), + UIView.animate( + withDuration: TimeInterval(duration.doubleValue), delay: 0, options: options, animations: { - UIApplication.sharedApplication().keyWindow?.layoutIfNeeded() + UIApplication.shared().keyWindow?.layoutIfNeeded() return }, completion: { finished in }) diff --git a/Spring/LoadingView.swift b/Spring/LoadingView.swift index 8ef23be..1172771 100644 --- a/Spring/LoadingView.swift +++ b/Spring/LoadingView.swift @@ -29,15 +29,16 @@ public class LoadingView: UIView { override public func awakeFromNib() { let animation = CABasicAnimation() animation.keyPath = "transform.rotation.z" - animation.fromValue = degreesToRadians(0) - animation.toValue = degreesToRadians(360) + animation.fromValue = degreesToRadians(degrees: 0) + animation.toValue = degreesToRadians(degrees: 360) animation.duration = 0.9 animation.repeatCount = HUGE - indicatorView.layer.addAnimation(animation, forKey: "") + indicatorView.layer.add(animation, forKey: "") } class func designCodeLoadingView() -> UIView { - return NSBundle(forClass: self).loadNibNamed("LoadingView", owner: self, options: nil)[0] as! UIView + + return Bundle(for: self).loadNibNamed("LoadingView", owner: self, options: nil)[0] as! UIView } } @@ -60,7 +61,7 @@ public extension UIView { self.addSubview(loadingXibView) loadingXibView.alpha = 0 - SpringAnimation.spring(0.7, animations: { + SpringAnimation.spring(duration: 0.7, animations: { loadingXibView.alpha = 1 }) } @@ -70,9 +71,9 @@ public extension UIView { if let loadingXibView = self.viewWithTag(LoadingViewConstants.Tag) { loadingXibView.alpha = 1 - SpringAnimation.springWithCompletion(0.7, animations: { + SpringAnimation.springWithCompletion(duration: 0.7, animations: { loadingXibView.alpha = 0 - loadingXibView.transform = CGAffineTransformMakeScale(3, 3) + loadingXibView.transform = CGAffineTransform(scaleX: 3, y: 3) }, completion: { (completed) -> Void in loadingXibView.removeFromSuperview() }) diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 532071d..49a5b33 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -30,11 +30,11 @@ public extension String { } } -public func htmlToAttributedString(text: String) -> NSAttributedString! { - let htmlData = text.dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false) - let htmlString: NSAttributedString? +public func htmlToAttributedString(text: String) -> AttributedString! { + let htmlData = text.data(using: String.Encoding.utf8, allowLossyConversion: false) + let htmlString: AttributedString? do { - htmlString = try NSAttributedString(data: htmlData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) + htmlString = try AttributedString(data: htmlData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) } catch _ { htmlString = nil } @@ -47,18 +47,21 @@ public func degreesToRadians(degrees: CGFloat) -> CGFloat { } public func delay(delay:Double, closure:()->()) { - dispatch_after( - dispatch_time( - DISPATCH_TIME_NOW, - Int64(delay * Double(NSEC_PER_SEC)) - ), - dispatch_get_main_queue(), closure) + dispatch_time( + dispatch_time_t(DISPATCH_TIME_NOW), + Int64(delay * Double(NSEC_PER_SEC)) + ).after( + when: dispatch_get_main_queue(), execute: closure) } -public func imageFromURL(URL: String) -> UIImage { - let url = NSURL(string: URL) - let data = NSData(contentsOfURL: url!) - return UIImage(data: data!)! +public func imageFromURL(Url: String) -> UIImage { + let url = URL(string: Url) + do { + let data = try Data(contentsOf: url!) + return UIImage(data: data)! + } catch { + UIImage(named: "") + } } public extension UIColor { @@ -70,13 +73,13 @@ public extension UIColor { var hex: String = hex if hex.hasPrefix("#") { - let index = hex.startIndex.advancedBy(1) + let index = hex.startIndex.advancedBy(n: 1) hex = hex.substringFromIndex(index) } - let scanner = NSScanner(string: hex) + let scanner = Scanner(string: hex) var hexValue: CUnsignedLongLong = 0 - if scanner.scanHexLongLong(&hexValue) { + if scanner.scanHexInt64(&hexValue) { switch (hex.characters.count) { case 3: red = CGFloat((hexValue & 0xF00) >> 8) / 15.0 @@ -121,15 +124,15 @@ public func UIColorFromRGB(rgbValue: UInt) -> UIColor { } public func stringFromDate(date: NSDate, format: String) -> String { - let dateFormatter = NSDateFormatter() + let dateFormatter = DateFormatter() dateFormatter.dateFormat = format - return dateFormatter.stringFromDate(date) + return dateFormatter.string(from: date as Date) } public func dateFromString(date: String, format: String) -> NSDate { - let dateFormatter = NSDateFormatter() + let dateFormatter = DateFormatter() dateFormatter.dateFormat = format - if let date = dateFormatter.dateFromString(date) { + if let date = dateFormatter.date(from: date) { return date } else { return NSDate(timeIntervalSince1970: 0) @@ -145,19 +148,19 @@ public func randomStringWithLength (len : Int) -> NSString { for _ in 0 ..< len { let length = UInt32 (letters.length) let rand = arc4random_uniform(length) - randomString.appendFormat("%C", letters.characterAtIndex(Int(rand))) + randomString.appendFormat("%C", letters.character(at: Int(rand))) } return randomString } public func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { - let calendar = NSCalendar.currentCalendar() - let unitFlags: NSCalendarUnit = [NSCalendarUnit.Minute, NSCalendarUnit.Hour, NSCalendarUnit.Day, NSCalendarUnit.WeekOfYear, NSCalendarUnit.Month, NSCalendarUnit.Year, NSCalendarUnit.Second] + let calendar = Calendar.current() + let unitFlags: Calendar.Unit = [Calendar.Unit.minute, Calendar.Unit.hour, Calendar.Unit.day, Calendar.Unit.weekOfYear, Calendar.Unit.month, Calendar.Unit.year, Calendar.Unit.second] let now = NSDate() - let earliest = now.earlierDate(date) + let earliest = now.earlierDate(date as Date) let latest = (earliest == now) ? date : now - let components: NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: []) + let components: NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest as Date, options: []) if (components.year >= 2) { return "\(components.year)y" @@ -213,4 +216,4 @@ public func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { return "now" } -} \ No newline at end of file +} diff --git a/Spring/SoundPlayer.swift b/Spring/SoundPlayer.swift index e29fc18..1fd706a 100644 --- a/Spring/SoundPlayer.swift +++ b/Spring/SoundPlayer.swift @@ -38,7 +38,7 @@ struct SoundPlayer { return } - if let url = NSBundle.mainBundle().URLForResource(soundFile, withExtension: nil) { + if let url = Bundle.main().urlForResource(soundFile, withExtension: nil) { var soundID : SystemSoundID = Internal.cache[url] ?? 0 @@ -55,6 +55,6 @@ struct SoundPlayer { } static func play(file: String) { - self.playSound(file) + self.playSound(soundFile: file) } } diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 0cd0d7a..ae3e833 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -65,7 +65,7 @@ public class Spring : NSObject { } func commonInit() { - NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: UIApplicationDidBecomeActiveNotification, object: nil) + NotificationCenter.defaultCenter().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: UIApplicationDidBecomeActiveNotification, object: nil) } func didBecomeActiveNotification(notification: NSNotification) { @@ -77,7 +77,7 @@ public class Spring : NSObject { } deinit { - NSNotificationCenter.defaultCenter().removeObserver(self, name: UIApplicationDidBecomeActiveNotification, object: nil) + NotificationCenter.default().removeObserver(self, name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } private var autostart: Bool { set { self.view.autostart = newValue } get { return self.view.autostart }} @@ -199,11 +199,11 @@ public class Spring : NSObject { animation.keyPath = "opacity" animation.fromValue = 1 animation.toValue = 0 - animation.timingFunction = getTimingFunction(curve) + animation.timingFunction = getTimingFunction(curve: curve) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) animation.autoreverses = true - layer.addAnimation(animation, forKey: "fade") + layer.add(animation, forKey: "fade") case .FadeInLeft: opacity = 0 x = 300*force @@ -234,23 +234,23 @@ public class Spring : NSObject { animation.keyPath = "position.x" animation.values = [0, 30*force, -30*force, 30*force, 0] animation.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - animation.timingFunction = getTimingFunction(curve) + animation.timingFunction = getTimingFunction(curve: curve) animation.duration = CFTimeInterval(duration) - animation.additive = true + animation.isAdditive = true animation.repeatCount = repeatCount animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(animation, forKey: "shake") + layer.add(animation, forKey: "shake") case .Pop: let animation = CAKeyframeAnimation() animation.keyPath = "transform.scale" animation.values = [0, 0.2*force, -0.2*force, 0.2*force, 0] animation.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - animation.timingFunction = getTimingFunction(curve) + animation.timingFunction = getTimingFunction(curve: curve) animation.duration = CFTimeInterval(duration) - animation.additive = true + animation.isAdditive = true animation.repeatCount = repeatCount animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(animation, forKey: "pop") + layer.add(animation, forKey: "pop") case .FlipX: rotate = 0 scaleX = 1 @@ -266,8 +266,8 @@ public class Spring : NSObject { CATransform3DConcat(perspective, CATransform3DMakeRotation(CGFloat(M_PI), 0, 1, 0))) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - animation.timingFunction = getTimingFunction(curve) - layer.addAnimation(animation, forKey: "3d") + animation.timingFunction = getTimingFunction(curve: curve) + layer.add(animation, forKey: "3d") case .FlipY: var perspective = CATransform3DIdentity perspective.m34 = -1.0 / layer.frame.size.width/2 @@ -280,48 +280,48 @@ public class Spring : NSObject { CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(M_PI), 1, 0, 0))) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - animation.timingFunction = getTimingFunction(curve) - layer.addAnimation(animation, forKey: "3d") + animation.timingFunction = getTimingFunction(curve: curve) + layer.add(animation, forKey: "3d") case .Morph: let morphX = CAKeyframeAnimation() morphX.keyPath = "transform.scale.x" morphX.values = [1, 1.3*force, 0.7, 1.3*force, 1] morphX.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - morphX.timingFunction = getTimingFunction(curve) + morphX.timingFunction = getTimingFunction(curve: curve) morphX.duration = CFTimeInterval(duration) morphX.repeatCount = repeatCount morphX.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(morphX, forKey: "morphX") + layer.add(morphX, forKey: "morphX") let morphY = CAKeyframeAnimation() morphY.keyPath = "transform.scale.y" morphY.values = [1, 0.7, 1.3*force, 0.7, 1] morphY.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - morphY.timingFunction = getTimingFunction(curve) + morphY.timingFunction = getTimingFunction(curve: curve) morphY.duration = CFTimeInterval(duration) morphY.repeatCount = repeatCount morphY.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(morphY, forKey: "morphY") + layer.add(morphY, forKey: "morphY") case .Squeeze: let morphX = CAKeyframeAnimation() morphX.keyPath = "transform.scale.x" morphX.values = [1, 1.5*force, 0.5, 1.5*force, 1] morphX.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - morphX.timingFunction = getTimingFunction(curve) + morphX.timingFunction = getTimingFunction(curve: curve) morphX.duration = CFTimeInterval(duration) morphX.repeatCount = repeatCount morphX.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(morphX, forKey: "morphX") + layer.add(morphX, forKey: "morphX") let morphY = CAKeyframeAnimation() morphY.keyPath = "transform.scale.y" morphY.values = [1, 0.5, 1, 0.5, 1] morphY.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - morphY.timingFunction = getTimingFunction(curve) + morphY.timingFunction = getTimingFunction(curve: curve) morphY.duration = CFTimeInterval(duration) morphY.repeatCount = repeatCount morphY.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(morphY, forKey: "morphY") + layer.add(morphY, forKey: "morphY") case .Flash: let animation = CABasicAnimation() animation.keyPath = "opacity" @@ -331,36 +331,36 @@ public class Spring : NSObject { animation.repeatCount = repeatCount * 2.0 animation.autoreverses = true animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(animation, forKey: "flash") + layer.add(animation, forKey: "flash") case .Wobble: let animation = CAKeyframeAnimation() animation.keyPath = "transform.rotation" animation.values = [0, 0.3*force, -0.3*force, 0.3*force, 0] animation.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] animation.duration = CFTimeInterval(duration) - animation.additive = true + animation.isAdditive = true animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(animation, forKey: "wobble") + layer.add(animation, forKey: "wobble") let x = CAKeyframeAnimation() x.keyPath = "position.x" x.values = [0, 30*force, -30*force, 30*force, 0] x.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] - x.timingFunction = getTimingFunction(curve) + x.timingFunction = getTimingFunction(curve: curve) x.duration = CFTimeInterval(duration) - x.additive = true + x.isAdditive = true x.repeatCount = repeatCount x.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(x, forKey: "x") + layer.add(x, forKey: "x") case .Swing: let animation = CAKeyframeAnimation() animation.keyPath = "transform.rotation" animation.values = [0, 0.3*force, -0.3*force, 0.3*force, 0] animation.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] animation.duration = CFTimeInterval(duration) - animation.additive = true + animation.isAdditive = true animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - layer.addAnimation(animation, forKey: "swing") + layer.add(animation, forKey: "swing") } } } @@ -405,13 +405,13 @@ public class Spring : NSObject { func getAnimationOptions(curve: String) -> UIViewAnimationOptions { if let curve = AnimationCurve(rawValue: curve) { switch curve { - case .EaseIn: return UIViewAnimationOptions.CurveEaseIn - case .EaseOut: return UIViewAnimationOptions.CurveEaseOut - case .EaseInOut: return UIViewAnimationOptions.CurveEaseInOut + case .EaseIn: return UIViewAnimationOptions.curveEaseIn + case .EaseOut: return UIViewAnimationOptions.curveEaseOut + case .EaseInOut: return UIViewAnimationOptions.curveEaseInOut default: break } } - return UIViewAnimationOptions.CurveLinear + return UIViewAnimationOptions.curveLinear } public func animate() { @@ -452,7 +452,7 @@ public class Spring : NSObject { if shouldAnimateInLayoutSubviews { shouldAnimateInLayoutSubviews = false if autostart { - if UIApplication.sharedApplication().applicationState != .Active { + if UIApplication.shared().applicationState != .active { shouldAnimateAfterActive = true return } @@ -464,20 +464,20 @@ public class Spring : NSObject { func setView(completion: () -> ()) { if animateFrom { - let translate = CGAffineTransformMakeTranslation(self.x, self.y) - let scale = CGAffineTransformMakeScale(self.scaleX, self.scaleY) - let rotate = CGAffineTransformMakeRotation(self.rotate) - let translateAndScale = CGAffineTransformConcat(translate, scale) - self.transform = CGAffineTransformConcat(rotate, translateAndScale) + let translate = CGAffineTransform(translationX: self.x, y: self.y) + let scale = CGAffineTransform(scaleX: self.scaleX, y: self.scaleY) + let rotate = CGAffineTransform(rotationAngle: self.rotate) + let translateAndScale = translate.concat(scale) + self.transform = rotate.concat(translateAndScale) self.alpha = self.opacity } - UIView.animateWithDuration( NSTimeInterval(duration), - delay: NSTimeInterval(delay), + UIView.animate( withDuration: TimeInterval(duration), + delay: TimeInterval(delay), usingSpringWithDamping: damping, initialSpringVelocity: velocity, - options: [getAnimationOptions(curve), UIViewAnimationOptions.AllowUserInteraction], + options: [getAnimationOptions(curve: curve), UIViewAnimationOptions.allowUserInteraction], animations: { [weak self] in if let _self = self { @@ -486,11 +486,11 @@ public class Spring : NSObject { _self.alpha = 1 } else { - let translate = CGAffineTransformMakeTranslation(_self.x, _self.y) - let scale = CGAffineTransformMakeScale(_self.scaleX, _self.scaleY) - let rotate = CGAffineTransformMakeRotation(_self.rotate) - let translateAndScale = CGAffineTransformConcat(translate, scale) - _self.transform = CGAffineTransformConcat(rotate, translateAndScale) + let translate = CGAffineTransform(translationX: _self.x, y: _self.y) + let scale = CGAffineTransform(scaleX: _self.scaleX, y: _self.scaleY) + let rotate = CGAffineTransform(rotationAngle: _self.rotate) + let translateAndScale = translate.concat(scale) + _self.transform = rotate.concat(translateAndScale) _self.alpha = _self.opacity } @@ -527,4 +527,4 @@ public class Spring : NSObject { duration = 0.7 } -} \ No newline at end of file +} diff --git a/Spring/SpringAnimation.swift b/Spring/SpringAnimation.swift index 51038c3..91310d8 100644 --- a/Spring/SpringAnimation.swift +++ b/Spring/SpringAnimation.swift @@ -23,9 +23,9 @@ import UIKit @objc public class SpringAnimation: NSObject { - public class func spring(duration: NSTimeInterval, animations: () -> Void) { - UIView.animateWithDuration( - duration, + public class func spring(duration: TimeInterval, animations: () -> Void) { + UIView.animate( + withDuration: duration, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.7, @@ -37,11 +37,11 @@ import UIKit ) } - public class func springEaseIn(duration: NSTimeInterval, animations: (() -> Void)!) { - UIView.animateWithDuration( - duration, + public class func springEaseIn(duration: TimeInterval, animations: (() -> Void)!) { + UIView.animate( + withDuration: duration, delay: 0, - options: .CurveEaseIn, + options: .curveEaseIn, animations: { animations() }, @@ -49,42 +49,42 @@ import UIKit ) } - public class func springEaseOut(duration: NSTimeInterval, animations: (() -> Void)!) { - UIView.animateWithDuration( - duration, + public class func springEaseOut(duration: TimeInterval, animations: (() -> Void)!) { + UIView.animate( + withDuration: duration, delay: 0, - options: .CurveEaseOut, + options: .curveEaseOut, animations: { animations() }, completion: nil ) } - public class func springEaseInOut(duration: NSTimeInterval, animations: (() -> Void)!) { - UIView.animateWithDuration( - duration, + public class func springEaseInOut(duration: TimeInterval, animations: (() -> Void)!) { + UIView.animate( + withDuration: duration, delay: 0, - options: .CurveEaseInOut, + options: .curveEaseInOut, animations: { animations() }, completion: nil ) } - public class func springLinear(duration: NSTimeInterval, animations: (() -> Void)!) { - UIView.animateWithDuration( - duration, + public class func springLinear(duration: TimeInterval, animations: (() -> Void)!) { + UIView.animate( + withDuration: duration, delay: 0, - options: .CurveLinear, + options: .curveLinear, animations: { animations() }, completion: nil ) } - public class func springWithDelay(duration: NSTimeInterval, delay: NSTimeInterval, animations: (() -> Void)!) { - UIView.animateWithDuration( - duration, + public class func springWithDelay(duration: TimeInterval, delay: TimeInterval, animations: (() -> Void)!) { + UIView.animate( + withDuration: duration, delay: delay, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.7, @@ -95,9 +95,9 @@ import UIKit ) } - public class func springWithCompletion(duration: NSTimeInterval, animations: (() -> Void)!, completion: (Bool -> Void)!) { - UIView.animateWithDuration( - duration, + public class func springWithCompletion(duration: TimeInterval, animations: (() -> Void)!, completion: ((Bool) -> Void)!) { + UIView.animate( + withDuration: duration, delay: 0, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.7, diff --git a/Spring/SpringTextField.swift b/Spring/SpringTextField.swift index ea30597..1a0100b 100644 --- a/Spring/SpringTextField.swift +++ b/Spring/SpringTextField.swift @@ -58,7 +58,7 @@ public class SpringTextField: UITextField, Springable { } public func animateNext(completion: () -> ()) { - self.spring.animateNext(completion) + self.spring.animateNext(completion: completion) } public func animateTo() { @@ -66,6 +66,6 @@ public class SpringTextField: UITextField, Springable { } public func animateToNext(completion: () -> ()) { - self.spring.animateToNext(completion) + self.spring.animateToNext(completion: completion) } -} \ No newline at end of file +} diff --git a/Spring/SpringTextView.swift b/Spring/SpringTextView.swift index 5b8f5f7..651fb06 100644 --- a/Spring/SpringTextView.swift +++ b/Spring/SpringTextView.swift @@ -58,7 +58,7 @@ public class SpringTextView: UITextView, Springable { } public func animateNext(completion: () -> ()) { - self.spring.animateNext(completion) + self.spring.animateNext(completion: completion) } public func animateTo() { @@ -66,7 +66,7 @@ public class SpringTextView: UITextView, Springable { } public func animateToNext(completion: () -> ()) { - self.spring.animateToNext(completion) + self.spring.animateToNext(completion: completion) } -} \ No newline at end of file +} diff --git a/Spring/SpringView.swift b/Spring/SpringView.swift index 405e2af..2ac0dac 100644 --- a/Spring/SpringView.swift +++ b/Spring/SpringView.swift @@ -58,7 +58,7 @@ public class SpringView: UIView, Springable { } public func animateNext(completion: () -> ()) { - self.spring.animateNext(completion) + self.spring.animateNext(completion: completion) } public func animateTo() { @@ -66,6 +66,6 @@ public class SpringView: UIView, Springable { } public func animateToNext(completion: () -> ()) { - self.spring.animateToNext(completion) + self.spring.animateToNext(completion: completion) } -} \ No newline at end of file +} diff --git a/Spring/TransitionManager.swift b/Spring/TransitionManager.swift index 1aee7c5..9703887 100644 --- a/Spring/TransitionManager.swift +++ b/Spring/TransitionManager.swift @@ -27,18 +27,18 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, var isPresenting = true var duration = 0.3 - public func animateTransition(transitionContext: UIViewControllerContextTransitioning) { - let container = transitionContext.containerView()! - let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)! - let toView = transitionContext.viewForKey(UITransitionContextToViewKey)! + public func animateTransition(_ transitionContext: UIViewControllerContextTransitioning) { + let container = transitionContext.containerView() + let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! + let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! if isPresenting { toView.frame = container.bounds - toView.transform = CGAffineTransformMakeTranslation(0, container.frame.size.height) + toView.transform = CGAffineTransform(translationX: 0, y: container.frame.size.height) container.addSubview(fromView) container.addSubview(toView) - SpringAnimation.springEaseInOut(duration) { - fromView.transform = CGAffineTransformMakeScale(0.8, 0.8) + SpringAnimation.springEaseInOut(duration: duration) { + fromView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) fromView.alpha = 0.5 toView.transform = CGAffineTransformIdentity } @@ -58,28 +58,28 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, container.addSubview(toView) container.addSubview(fromView) - SpringAnimation.springEaseInOut(duration) { - fromView.transform = CGAffineTransformMakeTranslation(0, fromView.frame.size.height) + SpringAnimation.springEaseInOut(duration: duration) { + fromView.transform = CGAffineTransform(translationX: 0, y: fromView.frame.size.height) toView.transform = CGAffineTransformIdentity toView.alpha = 1 } } - delay(duration, closure: { + delay(delay: duration, closure: { transitionContext.completeTransition(true) }) } - public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { + public func transitionDuration(_ transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { return duration } - public func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + public func animationController(forPresentedController presented: UIViewController, presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresenting = true return self } - public func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + public func animationController(forDismissedController dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresenting = false return self } diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index 92c43de..af37d1b 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -27,20 +27,20 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI var isPresenting = true var duration = 0.4 - public func animateTransition(transitionContext: UIViewControllerContextTransitioning) { - let container = transitionContext.containerView()! - let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)! - let toView = transitionContext.viewForKey(UITransitionContextToViewKey)! + public func animateTransition(_ transitionContext: UIViewControllerContextTransitioning) { + let container = transitionContext.containerView() + let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! + let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! if isPresenting { container.addSubview(fromView) container.addSubview(toView) toView.alpha = 0 - toView.transform = CGAffineTransformMakeScale(2, 2) + toView.transform = CGAffineTransform(scaleX: 2, y: 2) - SpringAnimation.springEaseInOut(duration) { - fromView.transform = CGAffineTransformMakeScale(0.5, 0.5) + SpringAnimation.springEaseInOut(duration: duration) { + fromView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) fromView.alpha = 0 toView.transform = CGAffineTransformIdentity toView.alpha = 1 @@ -50,30 +50,30 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI container.addSubview(toView) container.addSubview(fromView) - SpringAnimation.springEaseInOut(duration) { - fromView.transform = CGAffineTransformMakeScale(2, 2) + SpringAnimation.springEaseInOut(duration: duration) { + fromView.transform = CGAffineTransform(scaleX: 2, y: 2) fromView.alpha = 0 - toView.transform = CGAffineTransformMakeScale(1, 1) + toView.transform = CGAffineTransform(scaleX: 1, y: 1) toView.alpha = 1 } } - delay(duration, closure: { + delay(delay: duration, closure: { transitionContext.completeTransition(true) }) } - public func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval { + public func transitionDuration(_ transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { return duration } - public func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { + public func animationController(forPresentedController presented: UIViewController, presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresenting = true return self } - public func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + public func animationController(forDismissedController dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresenting = false return self } -} \ No newline at end of file +} diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index 5259b24..69ef340 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -413,16 +413,20 @@ TargetAttributes = { 1A4FDA321A6E44780099D309 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; }; 1A4FDA3C1A6E44780099D309 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; TestTargetID = 9641173A1A5BE90A000E3A5A; }; 9641173A1A5BE90A000E3A5A = { CreatedOnToolsVersion = 6.2; + LastSwiftMigration = 0800; }; 9641174F1A5BE90A000E3A5A = { CreatedOnToolsVersion = 6.2; + LastSwiftMigration = 0800; TestTargetID = 9641173A1A5BE90A000E3A5A; }; }; @@ -610,6 +614,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -632,6 +637,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -650,6 +656,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Debug; @@ -663,6 +670,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; @@ -756,6 +764,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -770,6 +779,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -786,6 +796,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Debug; @@ -799,6 +810,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; diff --git a/SpringApp/AppDelegate.swift b/SpringApp/AppDelegate.swift index 68f9cca..a2ed126 100644 --- a/SpringApp/AppDelegate.swift +++ b/SpringApp/AppDelegate.swift @@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/SpringApp/CodeViewController.swift b/SpringApp/CodeViewController.swift index 3b01f45..aa747f9 100644 --- a/SpringApp/CodeViewController.swift +++ b/SpringApp/CodeViewController.swift @@ -20,7 +20,7 @@ class CodeViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - modalView.transform = CGAffineTransformMakeTranslation(-300, 0) + modalView.transform = CGAffineTransform(translationX: -300, y: 0) if data.animation != "" { codeText += "layer.animation = \"\(data.animation)\"\n" @@ -57,8 +57,8 @@ class CodeViewController: UIViewController { codeTextView.text = codeText } - @IBAction func closeButtonPressed(sender: AnyObject) { - UIApplication.sharedApplication().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, forEvent: nil) + @IBAction func closeButtonPressed(_ sender: AnyObject) { + UIApplication.shared().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) modalView.animation = "slideRight" modalView.animateFrom = false @@ -67,11 +67,11 @@ class CodeViewController: UIViewController { }) } - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) modalView.animate() - UIApplication.sharedApplication().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, forEvent: nil) + UIApplication.shared().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, for: nil) } } diff --git a/SpringApp/OptionsViewController.swift b/SpringApp/OptionsViewController.swift index ebf7543..d98f7a5 100644 --- a/SpringApp/OptionsViewController.swift +++ b/SpringApp/OptionsViewController.swift @@ -10,13 +10,13 @@ import UIKit import Spring protocol OptionsViewControllerDelegate: class { - func dampingSliderChanged(sender: AnyObject) - func velocitySliderChanged(sender: AnyObject) - func scaleSliderChanged(sender: AnyObject) - func xSliderChanged(sender: AnyObject) - func ySliderChanged(sender: AnyObject) - func rotateSliderChanged(sender: AnyObject) - func resetButtonPressed(sender: AnyObject) + func dampingSliderChanged(_ sender: AnyObject) + func velocitySliderChanged(_ sender: AnyObject) + func scaleSliderChanged(_ sender: AnyObject) + func xSliderChanged(_ sender: AnyObject) + func ySliderChanged(_ sender: AnyObject) + func rotateSliderChanged(_ sender: AnyObject) + func resetButtonPressed(_ sender: AnyObject) } class OptionsViewController: UIViewController { @@ -50,7 +50,7 @@ class OptionsViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - modalView.transform = CGAffineTransformMakeTranslation(0, 300) + modalView.transform = CGAffineTransform(translationX: 0, y: 300) dampingSlider.setValue(Float(data.damping), animated: true) velocitySlider.setValue(Float(data.velocity), animated: true) @@ -67,64 +67,64 @@ class OptionsViewController: UIViewController { rotateLabel.text = getString("Rotate", value: data.rotate) } - @IBAction func dampingSliderChanged(sender: AnyObject) { - selectedDamping = sender.valueForKey("value") as! CGFloat + @IBAction func dampingSliderChanged(_ sender: AnyObject) { + selectedDamping = sender.value(forKey: "value") as! CGFloat delegate?.dampingSliderChanged(sender) dampingLabel.text = getString("Damping", value: selectedDamping) } - @IBAction func velocitySliderChanged(sender: AnyObject) { - selectedVelocity = sender.valueForKey("value") as! CGFloat + @IBAction func velocitySliderChanged(_ sender: AnyObject) { + selectedVelocity = sender.value(forKey: "value") as! CGFloat delegate?.velocitySliderChanged(sender) velocityLabel.text = getString("Velocity", value: selectedVelocity) } - @IBAction func scaleSliderChanged(sender: AnyObject) { - selectedScale = sender.valueForKey("value") as! CGFloat + @IBAction func scaleSliderChanged(_ sender: AnyObject) { + selectedScale = sender.value(forKey: "value") as! CGFloat delegate?.scaleSliderChanged(sender) scaleLabel.text = getString("Scale", value: selectedScale) } - @IBAction func xSliderChanged(sender: AnyObject) { - selectedX = sender.valueForKey("value") as! CGFloat + @IBAction func xSliderChanged(_ sender: AnyObject) { + selectedX = sender.value(forKey: "value") as! CGFloat delegate?.xSliderChanged(sender) xLabel.text = getString("X", value: selectedX) } - @IBAction func ySliderChanged(sender: AnyObject) { - selectedY = sender.valueForKey("value") as! CGFloat + @IBAction func ySliderChanged(_ sender: AnyObject) { + selectedY = sender.value(forKey: "value") as! CGFloat delegate?.ySliderChanged(sender) yLabel.text = getString("Y", value: selectedY) } - @IBAction func rotateSliderChanged(sender: AnyObject) { - selectedRotate = sender.valueForKey("value") as! CGFloat + @IBAction func rotateSliderChanged(_ sender: AnyObject) { + selectedRotate = sender.value(forKey: "value") as! CGFloat delegate?.rotateSliderChanged(sender) rotateLabel.text = getString("Rotate", value: selectedRotate) } - @IBAction func resetButtonPressed(sender: AnyObject) { + @IBAction func resetButtonPressed(_ sender: AnyObject) { delegate?.resetButtonPressed(sender) - dismissViewControllerAnimated(true, completion: nil) + dismiss(animated: true, completion: nil) - UIApplication.sharedApplication().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, forEvent: nil) + UIApplication.shared().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) } - @IBAction func closeButtonPressed(sender: AnyObject) { - dismissViewControllerAnimated(true, completion: nil) + @IBAction func closeButtonPressed(_ sender: AnyObject) { + dismiss(animated: true, completion: nil) - UIApplication.sharedApplication().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, forEvent: nil) + UIApplication.shared().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) } - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) - UIApplication.sharedApplication().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, forEvent: nil) + UIApplication.shared().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, for: nil) modalView.animate() } - func getString(name: String, value: CGFloat) -> String { + func getString(_ name: String, value: CGFloat) -> String { return String(format: "\(name): %.1f", Double(value)) } } diff --git a/SpringApp/SpringViewController.swift b/SpringApp/SpringViewController.swift index d621c14..0d8b2c9 100644 --- a/SpringApp/SpringViewController.swift +++ b/SpringApp/SpringViewController.swift @@ -34,49 +34,49 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView var selectedY: CGFloat = 0 var selectedRotate: CGFloat = 0 - @IBAction func forceSliderChanged(sender: AnyObject) { - selectedForce = sender.valueForKey("value") as! CGFloat + @IBAction func forceSliderChanged(_ sender: AnyObject) { + selectedForce = sender.value(forKey: "value") as! CGFloat animateView() forceLabel.text = String(format: "Force: %.1f", Double(selectedForce)) } - @IBAction func durationSliderChanged(sender: AnyObject) { - selectedDuration = sender.valueForKey("value") as! CGFloat + @IBAction func durationSliderChanged(_ sender: AnyObject) { + selectedDuration = sender.value(forKey: "value") as! CGFloat animateView() durationLabel.text = String(format: "Duration: %.1f", Double(selectedDuration)) } - @IBAction func delaySliderChanged(sender: AnyObject) { - selectedDelay = sender.valueForKey("value") as! CGFloat + @IBAction func delaySliderChanged(_ sender: AnyObject) { + selectedDelay = sender.value(forKey: "value") as! CGFloat animateView() delayLabel.text = String(format: "Delay: %.1f", Double(selectedDelay)) } - func dampingSliderChanged(sender: AnyObject) { - selectedDamping = sender.valueForKey("value") as! CGFloat + func dampingSliderChanged(_ sender: AnyObject) { + selectedDamping = sender.value(forKey: "value") as! CGFloat animateView() } - func velocitySliderChanged(sender: AnyObject) { - selectedVelocity = sender.valueForKey("value") as! CGFloat + func velocitySliderChanged(_ sender: AnyObject) { + selectedVelocity = sender.value(forKey: "value") as! CGFloat animateView() } - func scaleSliderChanged(sender: AnyObject) { - selectedScale = sender.valueForKey("value") as! CGFloat + func scaleSliderChanged(_ sender: AnyObject) { + selectedScale = sender.value(forKey: "value") as! CGFloat animateView() } - func xSliderChanged(sender: AnyObject) { - selectedX = sender.valueForKey("value") as! CGFloat + func xSliderChanged(_ sender: AnyObject) { + selectedX = sender.value(forKey: "value") as! CGFloat animateView() } - func ySliderChanged(sender: AnyObject) { - selectedY = sender.valueForKey("value") as! CGFloat + func ySliderChanged(_ sender: AnyObject) { + selectedY = sender.value(forKey: "value") as! CGFloat animateView() } - func rotateSliderChanged(sender: AnyObject) { - selectedRotate = sender.valueForKey("value") as! CGFloat + func rotateSliderChanged(_ sender: AnyObject) { + selectedRotate = sender.value(forKey: "value") as! CGFloat animateView() } @@ -102,18 +102,18 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView ballView.curve = animationCurves[selectedEasing].rawValue } - func minimizeView(sender: AnyObject) { + func minimizeView(_ sender: AnyObject) { SpringAnimation.spring(0.7, animations: { - self.view.transform = CGAffineTransformMakeScale(0.935, 0.935) + self.view.transform = CGAffineTransform(scaleX: 0.935, y: 0.935) }) - UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.LightContent, animated: true) + UIApplication.shared().setStatusBarStyle(UIStatusBarStyle.lightContent, animated: true) } - func maximizeView(sender: AnyObject) { + func maximizeView(_ sender: AnyObject) { SpringAnimation.spring(0.7, animations: { - self.view.transform = CGAffineTransformMakeScale(1, 1) + self.view.transform = CGAffineTransform(scaleX: 1, y: 1) }) - UIApplication.sharedApplication().setStatusBarStyle(UIStatusBarStyle.Default, animated: true) + UIApplication.shared().setStatusBarStyle(UIStatusBarStyle.default, animated: true) } let animations: [Spring.AnimationPreset] = [ @@ -185,7 +185,7 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView animationPicker.showsSelectionIndicator = true } - @IBAction func ballButtonPressed(sender: AnyObject) { + @IBAction func ballButtonPressed(_ sender: AnyObject) { UIView.animateWithDuration(0.1, animations: { self.ballView.backgroundColor = UIColor(hex: "69DBFF") @@ -212,11 +212,11 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView ballView.layer.addAnimation(animation, forKey: "radius") } - @IBAction func shapeButtonPressed(sender: AnyObject) { + @IBAction func shapeButtonPressed(_ sender: AnyObject) { changeBall() } - func resetButtonPressed(sender: AnyObject) { + func resetButtonPressed(_ sender: AnyObject) { selectedForce = 1 selectedDuration = 1 selectedDelay = 0 @@ -237,19 +237,19 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView delayLabel.text = String(format: "Delay: %.1f", Double(selectedDelay)) } - func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int { + func numberOfComponents(in pickerView: UIPickerView) -> Int { return 2 } - func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { + func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int { return component == 0 ? animations.count : animationCurves.count } - func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { + func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? { return component == 0 ? animations[row].rawValue : animationCurves[row].rawValue } - func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { + func pickerView(_ pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) { switch component { case 0: selectedRow = row @@ -260,7 +260,7 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView } } - override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) { if let optionsViewController = segue.destinationViewController as? OptionsViewController { optionsViewController.delegate = self setOptions() @@ -271,4 +271,4 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView codeViewController.data = ballView } } -} \ No newline at end of file +} diff --git a/SpringAppTests/SpringAppTests.swift b/SpringAppTests/SpringAppTests.swift index 2f0113b..ac2484b 100644 --- a/SpringAppTests/SpringAppTests.swift +++ b/SpringAppTests/SpringAppTests.swift @@ -28,7 +28,7 @@ class SpringAppTests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock() { + self.measure() { // Put the code you want to measure the time of here. } } diff --git a/SpringTests/SpringTests.swift b/SpringTests/SpringTests.swift index 105bf23..938737d 100644 --- a/SpringTests/SpringTests.swift +++ b/SpringTests/SpringTests.swift @@ -28,7 +28,7 @@ class SpringTests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock() { + self.measure() { // Put the code you want to measure the time of here. } } From 42b4f525f56671ae2f7b480a30784ea52335471c Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Fri, 8 Jul 2016 11:31:33 -0500 Subject: [PATCH 05/42] some more syntax error fixes --- Spring/DesignableTextField.swift | 6 +- Spring/ImageLoader.swift | 6 +- Spring/Misc.swift | 15 ++--- Spring/Spring.swift | 111 +++++++++++++++---------------- Spring/SpringButton.swift | 6 +- Spring/SpringLabel.swift | 6 +- Spring/TransitionManager.swift | 6 +- Spring/TransitionZoom.swift | 2 +- 8 files changed, 77 insertions(+), 81 deletions(-) diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index b19c0a3..958a903 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -34,7 +34,7 @@ import UIKit @IBInspectable public var sidePadding: CGFloat = 0 { didSet { - let padding = UIView(frame: CGRectMake(0, 0, sidePadding, sidePadding)) + let padding = UIView(frame: CGRect(x: 0, y: 0, width: sidePadding, height: sidePadding)) leftViewMode = UITextFieldViewMode.always leftView = padding @@ -46,7 +46,7 @@ import UIKit @IBInspectable public var leftPadding: CGFloat = 0 { didSet { - let padding = UIView(frame: CGRectMake(0, 0, leftPadding, 0)) + let padding = UIView(frame: CGRect(x: 0, y: 0, width: leftPadding, height: 0)) leftViewMode = UITextFieldViewMode.always leftView = padding @@ -55,7 +55,7 @@ import UIKit @IBInspectable public var rightPadding: CGFloat = 0 { didSet { - let padding = UIView(frame: CGRectMake(0, 0, rightPadding, 0)) + let padding = UIView(frame: CGRect(x: 0, y: 0, width: rightPadding, height: 0)) rightViewMode = UITextFieldViewMode.always rightView = padding diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index 829700e..df61d15 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -26,11 +26,11 @@ import Foundation public class ImageLoader { - var cache = Cache() + var cache = Cache() public class var sharedLoader : ImageLoader { - struct Static { - static let instance : ImageLoader = ImageLoader() + struct Static { + static let instance : ImageLoader = ImageLoader() } return Static.instance } diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 49a5b33..d9bf124 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -24,7 +24,7 @@ import UIKit public extension String { public var length: Int { return self.characters.count } - + public func toURL() -> NSURL? { return NSURL(string: self) } @@ -47,18 +47,15 @@ public func degreesToRadians(degrees: CGFloat) -> CGFloat { } public func delay(delay:Double, closure:()->()) { - dispatch_time( - dispatch_time_t(DISPATCH_TIME_NOW), - Int64(delay * Double(NSEC_PER_SEC)) - ).after( - when: dispatch_get_main_queue(), execute: closure) + DispatchQueue.main.after( + when: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure) } public func imageFromURL(Url: String) -> UIImage { let url = URL(string: Url) do { - let data = try Data(contentsOf: url!) - return UIImage(data: data)! + let data = try Data(contentsOf: url!) + return UIImage(data: data)! } catch { UIImage(named: "") } @@ -76,7 +73,7 @@ public extension UIColor { let index = hex.startIndex.advancedBy(n: 1) hex = hex.substringFromIndex(index) } - + let scanner = Scanner(string: hex) var hexValue: CUnsignedLongLong = 0 if scanner.scanHexInt64(&hexValue) { diff --git a/Spring/Spring.swift b/Spring/Spring.swift index ae3e833..4fc5b23 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -40,7 +40,7 @@ import UIKit var opacity: CGFloat { get set } var animateFrom: Bool { get set } var curve: String { get set } - + // UIView var layer : CALayer { get } var transform : CGAffineTransform { get set } @@ -53,21 +53,21 @@ import UIKit } public class Spring : NSObject { - + private unowned var view : Springable private var shouldAnimateAfterActive = false private var shouldAnimateInLayoutSubviews = true - + init(_ view: Springable) { self.view = view super.init() commonInit() } - + func commonInit() { - NotificationCenter.defaultCenter().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: UIApplicationDidBecomeActiveNotification, object: nil) + NotificationCenter.default().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } - + func didBecomeActiveNotification(notification: NSNotification) { if shouldAnimateAfterActive { alpha = 0 @@ -75,11 +75,11 @@ public class Spring : NSObject { shouldAnimateAfterActive = false } } - + deinit { NotificationCenter.default().removeObserver(self, name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } - + private var autostart: Bool { set { self.view.autostart = newValue } get { return self.view.autostart }} private var autohide: Bool { set { self.view.autohide = newValue } get { return self.view.autohide }} private var animation: String { set { self.view.animation = newValue } get { return self.view.animation }} @@ -97,12 +97,12 @@ public class Spring : NSObject { private var opacity: CGFloat { set { self.view.opacity = newValue } get { return self.view.opacity }} private var animateFrom: Bool { set { self.view.animateFrom = newValue } get { return self.view.animateFrom }} private var curve: String { set { self.view.curve = newValue } get { return self.view.curve }} - + // UIView private var layer : CALayer { return view.layer } private var transform : CGAffineTransform { get { return view.transform } set { view.transform = newValue }} private var alpha: CGFloat { get { return view.alpha } set { view.alpha = newValue } } - + public enum AnimationPreset: String { case SlideLeft = "slideLeft" case SlideRight = "slideRight" @@ -132,7 +132,7 @@ public class Spring : NSObject { case Wobble = "wobble" case Swing = "swing" } - + public enum AnimationCurve: String { case EaseIn = "easeIn" case EaseOut = "easeOut" @@ -164,7 +164,7 @@ public class Spring : NSObject { case EaseOutBack = "easeOutBack" case EaseInOutBack = "easeInOutBack" } - + func animatePreset() { alpha = 0.99 if let animation = AnimationPreset(rawValue: animation) { @@ -257,12 +257,11 @@ public class Spring : NSObject { scaleY = 1 var perspective = CATransform3DIdentity perspective.m34 = -1.0 / layer.frame.size.width/2 - + let animation = CABasicAnimation() animation.keyPath = "transform" - animation.fromValue = NSValue(CATransform3D: - CATransform3DMakeRotation(0, 0, 0, 0)) - animation.toValue = NSValue(CATransform3D: + animation.fromValue = NSValue(caTransform3D: CATransform3DMakeRotation(0, 0, 0, 0)) + animation.toValue = NSValue(caTransform3D: CATransform3DConcat(perspective, CATransform3DMakeRotation(CGFloat(M_PI), 0, 1, 0))) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) @@ -271,10 +270,10 @@ public class Spring : NSObject { case .FlipY: var perspective = CATransform3DIdentity perspective.m34 = -1.0 / layer.frame.size.width/2 - + let animation = CABasicAnimation() animation.keyPath = "transform" - animation.fromValue = NSValue(CATransform3D: + animation.fromValue = NSValue(caTransform3D: CATransform3DMakeRotation(0, 0, 0, 0)) animation.toValue = NSValue(CATransform3D: CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(M_PI), 1, 0, 0))) @@ -292,7 +291,7 @@ public class Spring : NSObject { morphX.repeatCount = repeatCount morphX.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(morphX, forKey: "morphX") - + let morphY = CAKeyframeAnimation() morphY.keyPath = "transform.scale.y" morphY.values = [1, 0.7, 1.3*force, 0.7, 1] @@ -312,7 +311,7 @@ public class Spring : NSObject { morphX.repeatCount = repeatCount morphX.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(morphX, forKey: "morphX") - + let morphY = CAKeyframeAnimation() morphY.keyPath = "transform.scale.y" morphY.values = [1, 0.5, 1, 0.5, 1] @@ -341,7 +340,7 @@ public class Spring : NSObject { animation.isAdditive = true animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(animation, forKey: "wobble") - + let x = CAKeyframeAnimation() x.keyPath = "position.x" x.values = [0, 30*force, -30*force, 30*force, 0] @@ -364,7 +363,7 @@ public class Spring : NSObject { } } } - + func getTimingFunction(curve: String) -> CAMediaTimingFunction { if let curve = AnimationCurve(rawValue: curve) { switch curve { @@ -401,7 +400,7 @@ public class Spring : NSObject { } return CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault) } - + func getAnimationOptions(curve: String) -> UIViewAnimationOptions { if let curve = AnimationCurve(rawValue: curve) { switch curve { @@ -413,13 +412,13 @@ public class Spring : NSObject { } return UIViewAnimationOptions.curveLinear } - + public func animate() { animateFrom = true animatePreset() setView {} } - + public func animateNext(completion: () -> ()) { animateFrom = true animatePreset() @@ -427,13 +426,13 @@ public class Spring : NSObject { completion() } } - + public func animateTo() { animateFrom = false animatePreset() setView {} } - + public func animateToNext(completion: () -> ()) { animateFrom = false animatePreset() @@ -461,7 +460,7 @@ public class Spring : NSObject { } } } - + func setView(completion: () -> ()) { if animateFrom { let translate = CGAffineTransform(translationX: self.x, y: self.y) @@ -469,34 +468,34 @@ public class Spring : NSObject { let rotate = CGAffineTransform(rotationAngle: self.rotate) let translateAndScale = translate.concat(scale) self.transform = rotate.concat(translateAndScale) - + self.alpha = self.opacity } - + UIView.animate( withDuration: TimeInterval(duration), - delay: TimeInterval(delay), - usingSpringWithDamping: damping, - initialSpringVelocity: velocity, - options: [getAnimationOptions(curve: curve), UIViewAnimationOptions.allowUserInteraction], - animations: { [weak self] in - if let _self = self - { - if _self.animateFrom { - _self.transform = CGAffineTransformIdentity - _self.alpha = 1 - } - else { - let translate = CGAffineTransform(translationX: _self.x, y: _self.y) - let scale = CGAffineTransform(scaleX: _self.scaleX, y: _self.scaleY) - let rotate = CGAffineTransform(rotationAngle: _self.rotate) - let translateAndScale = translate.concat(scale) - _self.transform = rotate.concat(translateAndScale) - - _self.alpha = _self.opacity - } - - } - + delay: TimeInterval(delay), + usingSpringWithDamping: damping, + initialSpringVelocity: velocity, + options: [getAnimationOptions(curve: curve), UIViewAnimationOptions.allowUserInteraction], + animations: { [weak self] in + if let _self = self + { + if _self.animateFrom { + _self.transform = CGAffineTransform.Identity + _self.alpha = 1 + } + else { + let translate = CGAffineTransform(translationX: _self.x, y: _self.y) + let scale = CGAffineTransform(scaleX: _self.scaleX, y: _self.scaleY) + let rotate = CGAffineTransform(rotationAngle: _self.rotate) + let translateAndScale = translate.concat(scale) + _self.transform = rotate.concat(translateAndScale) + + _self.alpha = _self.opacity + } + + } + }, completion: { [weak self] finished in completion() @@ -505,13 +504,13 @@ public class Spring : NSObject { }) } - + func reset() { x = 0 y = 0 opacity = 1 } - + func resetAll() { x = 0 y = 0 @@ -526,5 +525,5 @@ public class Spring : NSObject { delay = 0 duration = 0.7 } - + } diff --git a/Spring/SpringButton.swift b/Spring/SpringButton.swift index 7851c14..459c84d 100644 --- a/Spring/SpringButton.swift +++ b/Spring/SpringButton.swift @@ -58,7 +58,7 @@ public class SpringButton: UIButton, Springable { } public func animateNext(completion: () -> ()) { - self.spring.animateNext(completion) + self.spring.animateNext(completion: completion) } public func animateTo() { @@ -66,6 +66,6 @@ public class SpringButton: UIButton, Springable { } public func animateToNext(completion: () -> ()) { - self.spring.animateToNext(completion) + self.spring.animateToNext(completion: completion) } -} \ No newline at end of file +} diff --git a/Spring/SpringLabel.swift b/Spring/SpringLabel.swift index 6a70b6c..ee16df3 100644 --- a/Spring/SpringLabel.swift +++ b/Spring/SpringLabel.swift @@ -58,7 +58,7 @@ public class SpringLabel: UILabel, Springable { } public func animateNext(completion: () -> ()) { - self.spring.animateNext(completion) + self.spring.animateNext(completion: completion) } public func animateTo() { @@ -66,7 +66,7 @@ public class SpringLabel: UILabel, Springable { } public func animateToNext(completion: () -> ()) { - self.spring.animateToNext(completion) + self.spring.animateToNext(completion: completion) } -} \ No newline at end of file +} diff --git a/Spring/TransitionManager.swift b/Spring/TransitionManager.swift index 9703887..aec79b6 100644 --- a/Spring/TransitionManager.swift +++ b/Spring/TransitionManager.swift @@ -40,7 +40,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, SpringAnimation.springEaseInOut(duration: duration) { fromView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) fromView.alpha = 0.5 - toView.transform = CGAffineTransformIdentity + toView.transform = CGAffineTransform.identity } } else { @@ -51,7 +51,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, // the same time take consideration of // previous transformation when presenting let transform = toView.transform - toView.transform = CGAffineTransformIdentity + toView.transform = CGAffineTransform.identity toView.frame = container.bounds toView.transform = transform @@ -60,7 +60,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, SpringAnimation.springEaseInOut(duration: duration) { fromView.transform = CGAffineTransform(translationX: 0, y: fromView.frame.size.height) - toView.transform = CGAffineTransformIdentity + toView.transform = CGAffineTransform.identity toView.alpha = 1 } } diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index af37d1b..b6f86a2 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -42,7 +42,7 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI SpringAnimation.springEaseInOut(duration: duration) { fromView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) fromView.alpha = 0 - toView.transform = CGAffineTransformIdentity + toView.transform = CGAffineTransform.Identity toView.alpha = 1 } } From 4722b6c5688e34102c3bd0ebbb0b92dbaae859c5 Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Fri, 8 Jul 2016 11:46:15 -0500 Subject: [PATCH 06/42] error fixes for swift 3 --- Spring/AsyncButton.swift | 17 ++++---- Spring/AsyncImageView.swift | 2 +- Spring/DesignableTabBarController.swift | 10 ++--- Spring/ImageLoader.swift | 11 +++--- Spring/KeyboardLayoutConstraint.swift | 52 ++++++++++++------------- Spring/Misc.swift | 20 ++++------ Spring/Spring.swift | 8 ++-- Spring/SpringAnimation.swift | 2 +- Spring/TransitionZoom.swift | 2 +- 9 files changed, 61 insertions(+), 63 deletions(-) diff --git a/Spring/AsyncButton.swift b/Spring/AsyncButton.swift index 2c2804f..7d9f2db 100644 --- a/Spring/AsyncButton.swift +++ b/Spring/AsyncButton.swift @@ -23,21 +23,22 @@ import UIKit public class AsyncButton: UIButton { - + private var imageURL = [UInt:NSURL]() private var placeholderImage = [UInt:UIImage]() - - + + public func setImageURL(url: NSURL?, placeholderImage placeholder:UIImage?, forState state:UIControlState) { - + imageURL[state.rawValue] = url placeholderImage[state.rawValue] = placeholder - + if let urlString = url?.absoluteString { ImageLoader.sharedLoader.imageForUrl(urlString: urlString) { [weak self] image, url in - + if let strongSelf = self { - DispatchQueue.main().asynchronously(execute: { () -> Void in + + DispatchQueue.main.async(execute: { () -> Void in if strongSelf.imageURL[state.rawValue]?.absoluteString == url { strongSelf.setImage(image, for: state) } @@ -46,5 +47,5 @@ public class AsyncButton: UIButton { } } } - + } diff --git a/Spring/AsyncImageView.swift b/Spring/AsyncImageView.swift index 1f88a52..aa2f7e8 100644 --- a/Spring/AsyncImageView.swift +++ b/Spring/AsyncImageView.swift @@ -32,7 +32,7 @@ public class AsyncImageView: UIImageView { if let urlString = url?.absoluteString { ImageLoader.sharedLoader.imageForUrl(urlString: urlString) { [weak self] image, url in if let strongSelf = self { - DispatchQueue.main().asynchronously(execute: { () -> Void in + DispatchQueue.main.async(execute: { () -> Void in if strongSelf.url?.absoluteString == url { strongSelf.image = image ?? strongSelf.placeholderImage } diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index ff3a3c9..df0df9e 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -27,7 +27,7 @@ import UIKit @IBInspectable var normalTint: UIColor = UIColor.clear() { didSet { UITabBar.appearance().tintColor = normalTint - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], for: UIControlState.normal) + UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], for: UIControlState()) } } @@ -40,7 +40,7 @@ import UIKit @IBInspectable var fontName: String = "" { didSet { - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint, NSFontAttributeName: UIFont(name: fontName, size: 11)!], for: UIControlState.normal) + UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint, NSFontAttributeName: UIFont(name: fontName, size: 11)!], for: UIControlState()) } } @@ -109,10 +109,10 @@ extension UIImage { context!.scale(x: 1.0, y: -1.0); context!.setBlendMode(CGBlendMode.normal) - let rect = CGRect(0, 0, self.size.width, self.size.height) - CGContextClipToMask(context!, rect, self.cgImage!) + let rect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height) + context!.clipToMask(rect, mask: self.cgImage!) tintColor.setFill() - CGContextFillRect(context!, rect) + context!.fill(rect) let newImage = UIGraphicsGetImageFromCurrentImageContext()! as UIImage UIGraphicsEndImageContext() diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index df61d15..2d23793 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -36,18 +36,19 @@ public class ImageLoader { } public func imageForUrl(urlString: String, completionHandler:(image: UIImage?, url: String) -> ()) { - DispatchQueue.global(Int(UInt64(DispatchQueue.GlobalAttributes.qosBackground.rawValue)), 0).asynchronously(execute: {()in - let data: NSData? = self.cache.objectForKey(urlString) as? NSData + DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes.qosBackground).async(execute: {()in + let data: NSData? = self.cache.object(forKey: urlString)! as NSData if let goodData = data { let image = UIImage(data: goodData as Data) - DispatchQueue.main().asynchronously(execute: {() in + DispatchQueue.main.async(execute: {() in completionHandler(image: image, url: urlString) }) return } - let downloadTask: URLSessionDataTask = URLSession.sharedSession().dataTaskWithURL(NSURL(string: urlString)! as URL, completionHandler: { (data, response, error) -> Void in + let downloadTask: URLSessionDataTask = URLSession.shared().dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) -> Void in + if (error != nil) { completionHandler(image: nil, url: urlString) return @@ -56,7 +57,7 @@ public class ImageLoader { if data != nil { let image = UIImage(data: data!) self.cache.setObject(data!, forKey: urlString) - dispatch_async(dispatch_get_main_queue(), {() in + DispatchQueue.main.async(execute: {() in completionHandler(image: image, url: urlString) }) return diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 642a06e..f76264b 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -23,38 +23,38 @@ import UIKit public class KeyboardLayoutConstraint: NSLayoutConstraint { - + private var offset : CGFloat = 0 private var keyboardVisibleHeight : CGFloat = 0 - + override public func awakeFromNib() { super.awakeFromNib() - + offset = constant - - NotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: UIKeyboardWillShowNotification, object: nil) - NotificationCenter.defaultCenter().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: UIKeyboardWillHideNotification, object: nil) + + NotificationCenter.default().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) + NotificationCenter.default().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil) } - + deinit { NotificationCenter.default().removeObserver(self) } - + // MARK: Notification - - func keyboardWillShowNotification(notification: NSNotification) { + + func keyboardWillShowNotification(_ notification: Notification) { if let userInfo = notification.userInfo { if let frameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue { let frame = frameValue.cgRectValue() keyboardVisibleHeight = frame.size.height } - + self.updateConstant() switch (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber) { case let (.some(duration), .some(curve)): - - let options = UIViewAnimationOptions(rawValue: curve.unsignedLongValue) - + + let options = UIViewAnimationOptions(rawValue: curve.uintValue) + UIView.animate( withDuration: TimeInterval(duration.doubleValue), delay: 0, @@ -65,25 +65,25 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { }, completion: { finished in }) default: - + break } - + } - + } - - func keyboardWillHideNotification(notification: NSNotification) { + + func keyboardWillHideNotification(_ notification: NSNotification) { keyboardVisibleHeight = 0 self.updateConstant() - + if let userInfo = notification.userInfo { - + switch (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber) { case let (.some(duration), .some(curve)): - - let options = UIViewAnimationOptions(rawValue: curve.unsignedLongValue) - + + let options = UIViewAnimationOptions(rawValue: curve.uintValue) + UIView.animate( withDuration: TimeInterval(duration.doubleValue), delay: 0, @@ -98,9 +98,9 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { } } } - + func updateConstant() { self.constant = offset + keyboardVisibleHeight } - + } diff --git a/Spring/Misc.swift b/Spring/Misc.swift index d9bf124..18d813b 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -51,14 +51,10 @@ public func delay(delay:Double, closure:()->()) { when: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure) } -public func imageFromURL(Url: String) -> UIImage { - let url = URL(string: Url) - do { - let data = try Data(contentsOf: url!) - return UIImage(data: data)! - } catch { - UIImage(named: "") - } +public func imageFromURL(_ Url: String) -> UIImage { + let url = Foundation.URL(string: Url) + let data = try? Data(contentsOf: url!) + return UIImage(data: data!)! } public extension UIColor { @@ -70,8 +66,8 @@ public extension UIColor { var hex: String = hex if hex.hasPrefix("#") { - let index = hex.startIndex.advancedBy(n: 1) - hex = hex.substringFromIndex(index) + let index = hex.index(hex.startIndex, offsetBy: 1) + hex = hex.substring(from: index) } let scanner = Scanner(string: hex) @@ -157,7 +153,7 @@ public func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { let now = NSDate() let earliest = now.earlierDate(date as Date) let latest = (earliest == now) ? date : now - let components: NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest as Date, options: []) + let components: DateComponents = calendar.components(unitFlags, from: earliest, to: latest as Date, options: []) if (components.year >= 2) { return "\(components.year)y" @@ -168,7 +164,7 @@ public func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { return "1y" } } else if (components.month >= 2) { - return "\(components.month * 4)w" + return "\(components.month! * 4)w" } else if (components.month >= 1){ if (numericDates){ return "4w" diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 4fc5b23..6c2097d 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -68,7 +68,7 @@ public class Spring : NSObject { NotificationCenter.default().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } - func didBecomeActiveNotification(notification: NSNotification) { + func didBecomeActiveNotification(_ notification: NSNotification) { if shouldAnimateAfterActive { alpha = 0 animate() @@ -275,7 +275,7 @@ public class Spring : NSObject { animation.keyPath = "transform" animation.fromValue = NSValue(caTransform3D: CATransform3DMakeRotation(0, 0, 0, 0)) - animation.toValue = NSValue(CATransform3D: + animation.toValue = NSValue(caTransform3D: CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(M_PI), 1, 0, 0))) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) @@ -406,7 +406,7 @@ public class Spring : NSObject { switch curve { case .EaseIn: return UIViewAnimationOptions.curveEaseIn case .EaseOut: return UIViewAnimationOptions.curveEaseOut - case .EaseInOut: return UIViewAnimationOptions.curveEaseInOut + case .EaseInOut: return UIViewAnimationOptions() default: break } } @@ -481,7 +481,7 @@ public class Spring : NSObject { if let _self = self { if _self.animateFrom { - _self.transform = CGAffineTransform.Identity + _self.transform = CGAffineTransform.identity _self.alpha = 1 } else { diff --git a/Spring/SpringAnimation.swift b/Spring/SpringAnimation.swift index 91310d8..fd4e624 100644 --- a/Spring/SpringAnimation.swift +++ b/Spring/SpringAnimation.swift @@ -64,7 +64,7 @@ import UIKit UIView.animate( withDuration: duration, delay: 0, - options: .curveEaseInOut, + options: UIViewAnimationOptions(), animations: { animations() }, completion: nil diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index b6f86a2..d0f667f 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -42,7 +42,7 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI SpringAnimation.springEaseInOut(duration: duration) { fromView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) fromView.alpha = 0 - toView.transform = CGAffineTransform.Identity + toView.transform = CGAffineTransform.identity toView.alpha = 1 } } From 269c01c1215c673afabd3ea1b3b25010a8fb6206 Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Fri, 8 Jul 2016 11:47:09 -0500 Subject: [PATCH 07/42] more fixes in the sample app. --- SpringApp/CodeViewController.swift | 4 ++-- SpringApp/SpringViewController.swift | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SpringApp/CodeViewController.swift b/SpringApp/CodeViewController.swift index aa747f9..91e6fb0 100644 --- a/SpringApp/CodeViewController.swift +++ b/SpringApp/CodeViewController.swift @@ -62,8 +62,8 @@ class CodeViewController: UIViewController { modalView.animation = "slideRight" modalView.animateFrom = false - modalView.animateToNext({ - self.dismissViewControllerAnimated(false, completion: nil) + modalView.animateToNext(completion: { + self.dismiss(animated: false, completion: nil) }) } diff --git a/SpringApp/SpringViewController.swift b/SpringApp/SpringViewController.swift index 0d8b2c9..3c8124c 100644 --- a/SpringApp/SpringViewController.swift +++ b/SpringApp/SpringViewController.swift @@ -103,14 +103,14 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView } func minimizeView(_ sender: AnyObject) { - SpringAnimation.spring(0.7, animations: { + SpringAnimation.spring(duration: 0.7, animations: { self.view.transform = CGAffineTransform(scaleX: 0.935, y: 0.935) }) UIApplication.shared().setStatusBarStyle(UIStatusBarStyle.lightContent, animated: true) } func maximizeView(_ sender: AnyObject) { - SpringAnimation.spring(0.7, animations: { + SpringAnimation.spring(duration: 0.7, animations: { self.view.transform = CGAffineTransform(scaleX: 1, y: 1) }) UIApplication.shared().setStatusBarStyle(UIStatusBarStyle.default, animated: true) @@ -187,10 +187,10 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView @IBAction func ballButtonPressed(_ sender: AnyObject) { - UIView.animateWithDuration(0.1, animations: { + UIView.animate(withDuration: 0.1, animations: { self.ballView.backgroundColor = UIColor(hex: "69DBFF") }, completion: { finished in - UIView.animateWithDuration(0.5, animations: { + UIView.animate(withDuration: 0.5, animations: { self.ballView.backgroundColor = UIColor(hex: "#279CEB") }) }) @@ -209,7 +209,7 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView animation.toValue = cornerRadius animation.duration = 0.2 ballView.layer.cornerRadius = cornerRadius - ballView.layer.addAnimation(animation, forKey: "radius") + ballView.layer.add(animation, forKey: "radius") } @IBAction func shapeButtonPressed(_ sender: AnyObject) { From a82f55bbb5fe9ef910e6a556ebcf391c3a082be9 Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Fri, 8 Jul 2016 11:49:53 -0500 Subject: [PATCH 08/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 38d4a6a..97d6953 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](http://cl.ly/image/012R0D3R3x2g/download/springswift2.jpg) -## Updated for Swift 2 +## Updated for Swift 3.0 Requires Xcode 7 and Swift 2. ## Installation From 4a7bcbd2d1e7d6ecbc512202a9c6426236dffcd8 Mon Sep 17 00:00:00 2001 From: Meng To Date: Mon, 18 Jul 2016 12:21:35 -0400 Subject: [PATCH 09/42] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 97d6953..e8fd104 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ -![](http://cl.ly/image/012R0D3R3x2g/download/springswift2.jpg) - ## Updated for Swift 3.0 -Requires Xcode 7 and Swift 2. +Requires Xcode 8 and Swift 3. ## Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups"). @@ -9,7 +7,7 @@ Drop in the Spring folder to your Xcode project (make sure to enable "Copy items Or via CocoaPods: ``` use_frameworks! -pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift2' +pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift3' ``` ## Usage with Storyboard From de73ae4a55f282e3c583952070cd50437c083d59 Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Mon, 18 Jul 2016 11:22:01 -0500 Subject: [PATCH 10/42] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 97d6953..7489250 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ![](http://cl.ly/image/012R0D3R3x2g/download/springswift2.jpg) ## Updated for Swift 3.0 -Requires Xcode 7 and Swift 2. +Requires Xcode 8 and Swift 3. ## Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups"). @@ -9,7 +9,7 @@ Drop in the Spring folder to your Xcode project (make sure to enable "Copy items Or via CocoaPods: ``` use_frameworks! -pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift2' +pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift3' ``` ## Usage with Storyboard From 9f791bcaf423365f662a9d7d229ff32d0a8e01a2 Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Tue, 19 Jul 2016 14:36:16 -0500 Subject: [PATCH 11/42] Updated to Xcode 8 beta 3 --- Spring/ImageLoader.swift | 2 +- Spring/KeyboardLayoutConstraint.swift | 6 +++--- Spring/LoadingView.swift | 2 +- Spring/Misc.swift | 2 +- Spring/SoundPlayer.swift | 2 +- Spring/Spring.swift | 4 ++-- Spring/TransitionManager.swift | 6 +++--- Spring/TransitionZoom.swift | 6 +++--- SpringApp/Base.lproj/LaunchScreen.xib | 12 ++++++------ 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index 2d23793..933179e 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -47,7 +47,7 @@ public class ImageLoader { return } - let downloadTask: URLSessionDataTask = URLSession.shared().dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) -> Void in + let downloadTask: URLSessionDataTask = URLSession.shared.dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) -> Void in if (error != nil) { completionHandler(image: nil, url: urlString) diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index f76264b..079a941 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -32,12 +32,12 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { offset = constant - NotificationCenter.default().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default().addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil) } deinit { - NotificationCenter.default().removeObserver(self) + NotificationCenter.default.removeObserver(self) } // MARK: Notification diff --git a/Spring/LoadingView.swift b/Spring/LoadingView.swift index 1172771..047aaa9 100644 --- a/Spring/LoadingView.swift +++ b/Spring/LoadingView.swift @@ -38,7 +38,7 @@ public class LoadingView: UIView { class func designCodeLoadingView() -> UIView { - return Bundle(for: self).loadNibNamed("LoadingView", owner: self, options: nil)[0] as! UIView + return Bundle(for: self).loadNibNamed("LoadingView", owner: self, options: nil)![0] as! UIView } } diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 18d813b..7851f6b 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -148,7 +148,7 @@ public func randomStringWithLength (len : Int) -> NSString { } public func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { - let calendar = Calendar.current() + let calendar = Calendar.current let unitFlags: Calendar.Unit = [Calendar.Unit.minute, Calendar.Unit.hour, Calendar.Unit.day, Calendar.Unit.weekOfYear, Calendar.Unit.month, Calendar.Unit.year, Calendar.Unit.second] let now = NSDate() let earliest = now.earlierDate(date as Date) diff --git a/Spring/SoundPlayer.swift b/Spring/SoundPlayer.swift index 1fd706a..52879a3 100644 --- a/Spring/SoundPlayer.swift +++ b/Spring/SoundPlayer.swift @@ -38,7 +38,7 @@ struct SoundPlayer { return } - if let url = Bundle.main().urlForResource(soundFile, withExtension: nil) { + if let url = Bundle.main.urlForResource(soundFile, withExtension: nil) { var soundID : SystemSoundID = Internal.cache[url] ?? 0 diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 6c2097d..f388910 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -65,7 +65,7 @@ public class Spring : NSObject { } func commonInit() { - NotificationCenter.default().addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } func didBecomeActiveNotification(_ notification: NSNotification) { @@ -77,7 +77,7 @@ public class Spring : NSObject { } deinit { - NotificationCenter.default().removeObserver(self, name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) + NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } private var autostart: Bool { set { self.view.autostart = newValue } get { return self.view.autostart }} diff --git a/Spring/TransitionManager.swift b/Spring/TransitionManager.swift index aec79b6..b21ec11 100644 --- a/Spring/TransitionManager.swift +++ b/Spring/TransitionManager.swift @@ -27,7 +27,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, var isPresenting = true var duration = 0.3 - public func animateTransition(_ transitionContext: UIViewControllerContextTransitioning) { + public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { let container = transitionContext.containerView() let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! @@ -70,7 +70,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, }) } - public func transitionDuration(_ transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { return duration } @@ -79,7 +79,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, return self } - public func animationController(forDismissedController dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresenting = false return self } diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index d0f667f..b79ae6f 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -27,7 +27,7 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI var isPresenting = true var duration = 0.4 - public func animateTransition(_ transitionContext: UIViewControllerContextTransitioning) { + public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { let container = transitionContext.containerView() let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! @@ -63,7 +63,7 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI }) } - public func transitionDuration(_ transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { + public func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { return duration } @@ -72,7 +72,7 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI return self } - public func animationController(forDismissedController dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { + public func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? { isPresenting = false return self } diff --git a/SpringApp/Base.lproj/LaunchScreen.xib b/SpringApp/Base.lproj/LaunchScreen.xib index 3ace0e1..a13447c 100644 --- a/SpringApp/Base.lproj/LaunchScreen.xib +++ b/SpringApp/Base.lproj/LaunchScreen.xib @@ -1,7 +1,9 @@ - + - + + + @@ -11,15 +13,13 @@ - - + - - + From b6d03de82cf7edf087d648903e1f52cf2d62b2b3 Mon Sep 17 00:00:00 2001 From: Rishabh Tayal Date: Mon, 1 Aug 2016 14:56:27 -0500 Subject: [PATCH 12/42] Updated for Xcode 8 beta 4 --- Spring/AutoTextView.swift | 23 +++++++++++++---------- Spring/BlurView.swift | 2 +- Spring/DesignableButton.swift | 4 ++-- Spring/DesignableImageView.swift | 2 +- Spring/DesignableTabBarController.swift | 10 +++++----- Spring/DesignableTextField.swift | 6 +++--- Spring/DesignableTextView.swift | 2 +- Spring/DesignableView.swift | 4 ++-- Spring/ImageLoader.swift | 6 +++--- Spring/KeyboardLayoutConstraint.swift | 6 +++--- Spring/Misc.swift | 19 +++++++++---------- Spring/SoundPlayer.swift | 2 +- Spring/Spring.swift | 10 +++++----- Spring/TransitionManager.swift | 2 +- Spring/TransitionZoom.swift | 2 +- SpringApp/CodeViewController.swift | 4 ++-- SpringApp/OptionsViewController.swift | 6 +++--- SpringApp/SpringViewController.swift | 8 ++++---- 18 files changed, 60 insertions(+), 58 deletions(-) diff --git a/Spring/AutoTextView.swift b/Spring/AutoTextView.swift index 632f365..9a0dfd3 100644 --- a/Spring/AutoTextView.swift +++ b/Spring/AutoTextView.swift @@ -9,16 +9,19 @@ import UIKit public class AutoTextView: UITextView { - override public func intrinsicContentSize() -> CGSize { - var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude)) - size.width = self.frame.size.width - if text.length == 0 { - size.height = 0 + + public override var intrinsicContentSize: CGSize { + get { + var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude)) + size.width = self.frame.size.width + if text.length == 0 { + size.height = 0 + } + + contentInset = UIEdgeInsetsMake(-4, -4, -4, -4) + layoutIfNeeded() + + return size } - - contentInset = UIEdgeInsetsMake(-4, -4, -4, -4) - layoutIfNeeded() - - return size } } diff --git a/Spring/BlurView.swift b/Spring/BlurView.swift index 198d466..2defcf6 100644 --- a/Spring/BlurView.swift +++ b/Spring/BlurView.swift @@ -23,7 +23,7 @@ import UIKit public func insertBlurView (view: UIView, style: UIBlurEffectStyle) -> UIVisualEffectView { - view.backgroundColor = UIColor.clear() + view.backgroundColor = UIColor.clear let blurEffect = UIBlurEffect(style: style) let blurEffectView = UIVisualEffectView(effect: blurEffect) diff --git a/Spring/DesignableButton.swift b/Spring/DesignableButton.swift index 237e8a5..0612083 100644 --- a/Spring/DesignableButton.swift +++ b/Spring/DesignableButton.swift @@ -24,7 +24,7 @@ import UIKit @IBDesignable public class DesignableButton: SpringButton { - @IBInspectable public var borderColor: UIColor = UIColor.clear() { + @IBInspectable public var borderColor: UIColor = UIColor.clear { didSet { layer.borderColor = borderColor.cgColor } @@ -42,7 +42,7 @@ import UIKit } } - @IBInspectable public var shadowColor: UIColor = UIColor.clear() { + @IBInspectable public var shadowColor: UIColor = UIColor.clear { didSet { layer.shadowColor = shadowColor.cgColor } diff --git a/Spring/DesignableImageView.swift b/Spring/DesignableImageView.swift index 93b0992..32a90a2 100644 --- a/Spring/DesignableImageView.swift +++ b/Spring/DesignableImageView.swift @@ -24,7 +24,7 @@ import UIKit @IBDesignable public class DesignableImageView: SpringImageView { - @IBInspectable public var borderColor: UIColor = UIColor.clear() { + @IBInspectable public var borderColor: UIColor = UIColor.clear { didSet { layer.borderColor = borderColor.cgColor } diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index df0df9e..4e55cfc 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -24,14 +24,14 @@ import UIKit @IBDesignable class DesignableTabBarController: UITabBarController { - @IBInspectable var normalTint: UIColor = UIColor.clear() { + @IBInspectable var normalTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = normalTint UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], for: UIControlState()) } } - @IBInspectable var selectedTint: UIColor = UIColor.clear() { + @IBInspectable var selectedTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = selectedTint UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: selectedTint], for:UIControlState.selected) @@ -105,12 +105,12 @@ extension UIImage { UIGraphicsBeginImageContextWithOptions(self.size, false, self.scale) let context = UIGraphicsGetCurrentContext() - context!.translate(x: 0, y: self.size.height) - context!.scale(x: 1.0, y: -1.0); + context!.translateBy(x: 0, y: self.size.height) + context!.scaleBy(x: 1.0, y: -1.0); context!.setBlendMode(CGBlendMode.normal) let rect = CGRect(x: 0, y: 0, width: self.size.width, height: self.size.height) - context!.clipToMask(rect, mask: self.cgImage!) + context?.clip(to: rect, mask: self.cgImage!) tintColor.setFill() context!.fill(rect) diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index 958a903..8cf32d0 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -24,9 +24,9 @@ import UIKit @IBDesignable public class DesignableTextField: SpringTextField { - @IBInspectable public var placeholderColor: UIColor = UIColor.clear() { + @IBInspectable public var placeholderColor: UIColor = UIColor.clear { didSet { - attributedPlaceholder = AttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor]) + attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor]) layoutSubviews() } @@ -62,7 +62,7 @@ import UIKit } } - @IBInspectable public var borderColor: UIColor = UIColor.clear() { + @IBInspectable public var borderColor: UIColor = UIColor.clear { didSet { layer.borderColor = borderColor.cgColor } diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index 2c0e64e..630941c 100644 --- a/Spring/DesignableTextView.swift +++ b/Spring/DesignableTextView.swift @@ -24,7 +24,7 @@ import UIKit @IBDesignable public class DesignableTextView: SpringTextView { - @IBInspectable public var borderColor: UIColor = UIColor.clear() { + @IBInspectable public var borderColor: UIColor = UIColor.clear { didSet { layer.borderColor = borderColor.cgColor } diff --git a/Spring/DesignableView.swift b/Spring/DesignableView.swift index 189f10d..a82d23f 100644 --- a/Spring/DesignableView.swift +++ b/Spring/DesignableView.swift @@ -24,7 +24,7 @@ import UIKit @IBDesignable public class DesignableView: SpringView { - @IBInspectable public var borderColor: UIColor = UIColor.clear() { + @IBInspectable public var borderColor: UIColor = UIColor.clear { didSet { layer.borderColor = borderColor.cgColor } @@ -42,7 +42,7 @@ import UIKit } } - @IBInspectable public var shadowColor: UIColor = UIColor.clear() { + @IBInspectable public var shadowColor: UIColor = UIColor.clear { didSet { layer.shadowColor = shadowColor.cgColor } diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index 933179e..bafd857 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -26,7 +26,7 @@ import Foundation public class ImageLoader { - var cache = Cache() + var cache = NSCache() public class var sharedLoader : ImageLoader { struct Static { @@ -36,7 +36,7 @@ public class ImageLoader { } public func imageForUrl(urlString: String, completionHandler:(image: UIImage?, url: String) -> ()) { - DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes.qosBackground).async(execute: {()in + DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async { let data: NSData? = self.cache.object(forKey: urlString)! as NSData if let goodData = data { @@ -65,7 +65,7 @@ public class ImageLoader { }) downloadTask.resume() - }) + } } } diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 079a941..57ef6f8 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -45,7 +45,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { func keyboardWillShowNotification(_ notification: Notification) { if let userInfo = notification.userInfo { if let frameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue { - let frame = frameValue.cgRectValue() + let frame = frameValue.cgRectValue keyboardVisibleHeight = frame.size.height } @@ -60,7 +60,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { delay: 0, options: options, animations: { - UIApplication.shared().keyWindow?.layoutIfNeeded() + UIApplication.shared.keyWindow?.layoutIfNeeded() return }, completion: { finished in }) @@ -89,7 +89,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { delay: 0, options: options, animations: { - UIApplication.shared().keyWindow?.layoutIfNeeded() + UIApplication.shared.keyWindow?.layoutIfNeeded() return }, completion: { finished in }) diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 7851f6b..2b0394b 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -30,11 +30,11 @@ public extension String { } } -public func htmlToAttributedString(text: String) -> AttributedString! { +public func htmlToAttributedString(text: String) -> NSAttributedString! { let htmlData = text.data(using: String.Encoding.utf8, allowLossyConversion: false) - let htmlString: AttributedString? + let htmlString: NSAttributedString? do { - htmlString = try AttributedString(data: htmlData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) + htmlString = try NSAttributedString(data: htmlData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) } catch _ { htmlString = nil } @@ -47,8 +47,7 @@ public func degreesToRadians(degrees: CGFloat) -> CGFloat { } public func delay(delay:Double, closure:()->()) { - DispatchQueue.main.after( - when: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure) + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure) } public func imageFromURL(_ Url: String) -> UIImage { @@ -147,14 +146,14 @@ public func randomStringWithLength (len : Int) -> NSString { return randomString } -public func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { +public func timeAgoSinceDate(date: Date, numericDates:Bool) -> String { let calendar = Calendar.current - let unitFlags: Calendar.Unit = [Calendar.Unit.minute, Calendar.Unit.hour, Calendar.Unit.day, Calendar.Unit.weekOfYear, Calendar.Unit.month, Calendar.Unit.year, Calendar.Unit.second] + let unitFlags = Set(arrayLiteral: Calendar.Component.minute, Calendar.Component.hour, Calendar.Component.day, Calendar.Component.weekOfYear, Calendar.Component.month, Calendar.Component.year, Calendar.Component.second) let now = NSDate() - let earliest = now.earlierDate(date as Date) + let earliest = now.earlierDate(date) let latest = (earliest == now) ? date : now - let components: DateComponents = calendar.components(unitFlags, from: earliest, to: latest as Date, options: []) - + let components: DateComponents = calendar.dateComponents(unitFlags, from: earliest, to: latest as Date) + if (components.year >= 2) { return "\(components.year)y" } else if (components.year >= 1){ diff --git a/Spring/SoundPlayer.swift b/Spring/SoundPlayer.swift index 52879a3..1624439 100644 --- a/Spring/SoundPlayer.swift +++ b/Spring/SoundPlayer.swift @@ -38,7 +38,7 @@ struct SoundPlayer { return } - if let url = Bundle.main.urlForResource(soundFile, withExtension: nil) { + if let url = Bundle.main.url(forResource: soundFile, withExtension: nil) { var soundID : SystemSoundID = Internal.cache[url] ?? 0 diff --git a/Spring/Spring.swift b/Spring/Spring.swift index f388910..978abca 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -451,7 +451,7 @@ public class Spring : NSObject { if shouldAnimateInLayoutSubviews { shouldAnimateInLayoutSubviews = false if autostart { - if UIApplication.shared().applicationState != .active { + if UIApplication.shared.applicationState != .active { shouldAnimateAfterActive = true return } @@ -466,8 +466,8 @@ public class Spring : NSObject { let translate = CGAffineTransform(translationX: self.x, y: self.y) let scale = CGAffineTransform(scaleX: self.scaleX, y: self.scaleY) let rotate = CGAffineTransform(rotationAngle: self.rotate) - let translateAndScale = translate.concat(scale) - self.transform = rotate.concat(translateAndScale) + let translateAndScale = translate.concatenating(scale) + self.transform = rotate.concatenating(translateAndScale) self.alpha = self.opacity } @@ -488,8 +488,8 @@ public class Spring : NSObject { let translate = CGAffineTransform(translationX: _self.x, y: _self.y) let scale = CGAffineTransform(scaleX: _self.scaleX, y: _self.scaleY) let rotate = CGAffineTransform(rotationAngle: _self.rotate) - let translateAndScale = translate.concat(scale) - _self.transform = rotate.concat(translateAndScale) + let translateAndScale = translate.concatenating(scale) + _self.transform = rotate.concatenating(translateAndScale) _self.alpha = _self.opacity } diff --git a/Spring/TransitionManager.swift b/Spring/TransitionManager.swift index b21ec11..5cb1eff 100644 --- a/Spring/TransitionManager.swift +++ b/Spring/TransitionManager.swift @@ -28,7 +28,7 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, var duration = 0.3 public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { - let container = transitionContext.containerView() + let container = transitionContext.containerView let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index b79ae6f..9dfb89a 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -28,7 +28,7 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI var duration = 0.4 public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { - let container = transitionContext.containerView() + let container = transitionContext.containerView let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! diff --git a/SpringApp/CodeViewController.swift b/SpringApp/CodeViewController.swift index 91e6fb0..fbdf459 100644 --- a/SpringApp/CodeViewController.swift +++ b/SpringApp/CodeViewController.swift @@ -58,7 +58,7 @@ class CodeViewController: UIViewController { } @IBAction func closeButtonPressed(_ sender: AnyObject) { - UIApplication.shared().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) + UIApplication.shared.sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) modalView.animation = "slideRight" modalView.animateFrom = false @@ -72,6 +72,6 @@ class CodeViewController: UIViewController { modalView.animate() - UIApplication.shared().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, for: nil) + UIApplication.shared.sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, for: nil) } } diff --git a/SpringApp/OptionsViewController.swift b/SpringApp/OptionsViewController.swift index d98f7a5..be62011 100644 --- a/SpringApp/OptionsViewController.swift +++ b/SpringApp/OptionsViewController.swift @@ -107,19 +107,19 @@ class OptionsViewController: UIViewController { delegate?.resetButtonPressed(sender) dismiss(animated: true, completion: nil) - UIApplication.shared().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) + UIApplication.shared.sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) } @IBAction func closeButtonPressed(_ sender: AnyObject) { dismiss(animated: true, completion: nil) - UIApplication.shared().sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) + UIApplication.shared.sendAction(#selector(SpringViewController.maximizeView(_:)), to: nil, from: self, for: nil) } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) - UIApplication.shared().sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, for: nil) + UIApplication.shared.sendAction(#selector(SpringViewController.minimizeView(_:)), to: nil, from: self, for: nil) modalView.animate() } diff --git a/SpringApp/SpringViewController.swift b/SpringApp/SpringViewController.swift index 3c8124c..7608843 100644 --- a/SpringApp/SpringViewController.swift +++ b/SpringApp/SpringViewController.swift @@ -106,14 +106,14 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView SpringAnimation.spring(duration: 0.7, animations: { self.view.transform = CGAffineTransform(scaleX: 0.935, y: 0.935) }) - UIApplication.shared().setStatusBarStyle(UIStatusBarStyle.lightContent, animated: true) + UIApplication.shared.setStatusBarStyle(UIStatusBarStyle.lightContent, animated: true) } func maximizeView(_ sender: AnyObject) { SpringAnimation.spring(duration: 0.7, animations: { self.view.transform = CGAffineTransform(scaleX: 1, y: 1) }) - UIApplication.shared().setStatusBarStyle(UIStatusBarStyle.default, animated: true) + UIApplication.shared.setStatusBarStyle(UIStatusBarStyle.default, animated: true) } let animations: [Spring.AnimationPreset] = [ @@ -261,12 +261,12 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView } override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) { - if let optionsViewController = segue.destinationViewController as? OptionsViewController { + if let optionsViewController = segue.destination as? OptionsViewController { optionsViewController.delegate = self setOptions() optionsViewController.data = ballView } - else if let codeViewController = segue.destinationViewController as? CodeViewController { + else if let codeViewController = segue.destination as? CodeViewController { setOptions() codeViewController.data = ballView } From d791055bc43bba9af8124d2832c2d8cd95ecfc11 Mon Sep 17 00:00:00 2001 From: Sammy Gutierrez Date: Mon, 22 Aug 2016 20:22:06 -0500 Subject: [PATCH 13/42] Updated for Xcode 8 beta 6 --- Spring/ImageLoader.swift | 12 ++--- Spring/Misc.swift | 79 ++++++++++++++++++---------- Spring/SoundPlayer.swift | 4 +- Spring/Spring.swift | 10 ++-- Spring/SpringAnimation.swift | 2 +- Spring/SpringButton.swift | 4 +- Spring/SpringImageView.swift | 4 +- Spring/SpringLabel.swift | 4 +- Spring/SpringTextField.swift | 4 +- Spring/SpringTextView.swift | 4 +- Spring/SpringView.swift | 4 +- Spring/TransitionManager.swift | 4 +- Spring/TransitionZoom.swift | 4 +- SpringApp/AppDelegate.swift | 3 +- SpringApp/SpringViewController.swift | 2 +- 15 files changed, 83 insertions(+), 61 deletions(-) diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index bafd857..263e1af 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -35,14 +35,14 @@ public class ImageLoader { return Static.instance } - public func imageForUrl(urlString: String, completionHandler:(image: UIImage?, url: String) -> ()) { + public func imageForUrl(urlString: String, completionHandler: @escaping(_ image: UIImage?, _ url: String) -> ()) { DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async { - let data: NSData? = self.cache.object(forKey: urlString)! as NSData + let data: NSData? = self.cache.object(forKey: urlString as NSString)! as NSData if let goodData = data { let image = UIImage(data: goodData as Data) DispatchQueue.main.async(execute: {() in - completionHandler(image: image, url: urlString) + completionHandler(image, urlString) }) return } @@ -50,15 +50,15 @@ public class ImageLoader { let downloadTask: URLSessionDataTask = URLSession.shared.dataTask(with: URL(string: urlString)!, completionHandler: { (data, response, error) -> Void in if (error != nil) { - completionHandler(image: nil, url: urlString) + completionHandler(nil, urlString) return } if data != nil { let image = UIImage(data: data!) - self.cache.setObject(data!, forKey: urlString) + self.cache.setObject(data! as NSData, forKey: urlString as NSString) DispatchQueue.main.async(execute: {() in - completionHandler(image: image, url: urlString) + completionHandler(image, urlString) }) return } diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 2b0394b..95cb32b 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -46,7 +46,7 @@ public func degreesToRadians(degrees: CGFloat) -> CGFloat { return degrees * CGFloat(M_PI / 180) } -public func delay(delay:Double, closure:()->()) { +public func delay(delay:Double, closure: @escaping ()->()) { DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC), execute: closure) } @@ -121,13 +121,13 @@ public func stringFromDate(date: NSDate, format: String) -> String { return dateFormatter.string(from: date as Date) } -public func dateFromString(date: String, format: String) -> NSDate { +public func dateFromString(date: String, format: String) -> Date { let dateFormatter = DateFormatter() dateFormatter.dateFormat = format if let date = dateFormatter.date(from: date) { return date } else { - return NSDate(timeIntervalSince1970: 0) + return Date(timeIntervalSince1970: 0) } } @@ -146,64 +146,87 @@ public func randomStringWithLength (len : Int) -> NSString { return randomString } -public func timeAgoSinceDate(date: Date, numericDates:Bool) -> String { +public func timeAgoSinceDate(date: Date, numericDates: Bool) -> String { let calendar = Calendar.current let unitFlags = Set(arrayLiteral: Calendar.Component.minute, Calendar.Component.hour, Calendar.Component.day, Calendar.Component.weekOfYear, Calendar.Component.month, Calendar.Component.year, Calendar.Component.second) - let now = NSDate() - let earliest = now.earlierDate(date) - let latest = (earliest == now) ? date : now - let components: DateComponents = calendar.dateComponents(unitFlags, from: earliest, to: latest as Date) - - if (components.year >= 2) { - return "\(components.year)y" - } else if (components.year >= 1){ + let now = Date() + let dateComparison = now.compare(date) + var earliest: Date + var latest: Date + + switch dateComparison { + case .orderedAscending: + earliest = now + latest = date + default: + earliest = date + latest = now + } + + let components: DateComponents = calendar.dateComponents(unitFlags, from: earliest, to: latest) + + guard + let year = components.year, + let month = components.month, + let weekOfYear = components.weekOfYear, + let day = components.day, + let hour = components.hour, + let minute = components.minute, + let second = components.second + else { + fatalError() + } + + if (year >= 2) { + return "\(year)y" + } else if (year >= 1) { if (numericDates){ return "1y" } else { return "1y" } - } else if (components.month >= 2) { - return "\(components.month! * 4)w" - } else if (components.month >= 1){ + } else if (month >= 2) { + return "\(month * 4)w" + } else if (month >= 1) { if (numericDates){ return "4w" } else { return "4w" } - } else if (components.weekOfYear >= 2) { - return "\(components.weekOfYear)w" - } else if (components.weekOfYear >= 1){ + } else if (weekOfYear >= 2) { + return "\(weekOfYear)w" + } else if (weekOfYear >= 1){ if (numericDates){ return "1w" } else { return "1w" } - } else if (components.day >= 2) { + } else if (day >= 2) { return "\(components.day)d" - } else if (components.day >= 1){ + } else if (day >= 1){ if (numericDates){ return "1d" } else { return "1d" } - } else if (components.hour >= 2) { - return "\(components.hour)h" - } else if (components.hour >= 1){ + } else if (hour >= 2) { + return "\(hour)h" + } else if (hour >= 1){ if (numericDates){ return "1h" } else { return "1h" } - } else if (components.minute >= 2) { - return "\(components.minute)m" - } else if (components.minute >= 1){ + } else if (minute >= 2) { + return "\(minute)m" + } else if (minute >= 1){ if (numericDates){ return "1m" } else { return "1m" } - } else if (components.second >= 3) { - return "\(components.second)s" + } else if (second >= 3) { + return "\(second)s" } else { return "now" } diff --git a/Spring/SoundPlayer.swift b/Spring/SoundPlayer.swift index 1624439..122ba42 100644 --- a/Spring/SoundPlayer.swift +++ b/Spring/SoundPlayer.swift @@ -29,7 +29,7 @@ struct SoundPlayer { static var enabled : Bool = true private struct Internal { - static var cache = [NSURL:SystemSoundID]() + static var cache = [URL:SystemSoundID]() } static func playSound(soundFile: String) { @@ -43,7 +43,7 @@ struct SoundPlayer { var soundID : SystemSoundID = Internal.cache[url] ?? 0 if soundID == 0 { - AudioServicesCreateSystemSoundID(url, &soundID) + AudioServicesCreateSystemSoundID(url as CFURL, &soundID) Internal.cache[url] = soundID } diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 978abca..46819b1 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -47,9 +47,9 @@ import UIKit var alpha : CGFloat { get set } func animate() - func animateNext(completion: () -> ()) + func animateNext(completion: @escaping () -> ()) func animateTo() - func animateToNext(completion: () -> ()) + func animateToNext(completion: @escaping () -> ()) } public class Spring : NSObject { @@ -419,7 +419,7 @@ public class Spring : NSObject { setView {} } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { animateFrom = true animatePreset() setView { @@ -433,7 +433,7 @@ public class Spring : NSObject { setView {} } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { animateFrom = false animatePreset() setView { @@ -461,7 +461,7 @@ public class Spring : NSObject { } } - func setView(completion: () -> ()) { + func setView(completion: @escaping () -> ()) { if animateFrom { let translate = CGAffineTransform(translationX: self.x, y: self.y) let scale = CGAffineTransform(scaleX: self.scaleX, y: self.scaleY) diff --git a/Spring/SpringAnimation.swift b/Spring/SpringAnimation.swift index fd4e624..e237d3d 100644 --- a/Spring/SpringAnimation.swift +++ b/Spring/SpringAnimation.swift @@ -23,7 +23,7 @@ import UIKit @objc public class SpringAnimation: NSObject { - public class func spring(duration: TimeInterval, animations: () -> Void) { + public class func spring(duration: TimeInterval, animations: @escaping () -> Void) { UIView.animate( withDuration: duration, delay: 0, diff --git a/Spring/SpringButton.swift b/Spring/SpringButton.swift index 459c84d..a4d7e8f 100644 --- a/Spring/SpringButton.swift +++ b/Spring/SpringButton.swift @@ -57,7 +57,7 @@ public class SpringButton: UIButton, Springable { self.spring.animate() } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } @@ -65,7 +65,7 @@ public class SpringButton: UIButton, Springable { self.spring.animateTo() } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } } diff --git a/Spring/SpringImageView.swift b/Spring/SpringImageView.swift index 8cd9ab2..1da8046 100644 --- a/Spring/SpringImageView.swift +++ b/Spring/SpringImageView.swift @@ -57,7 +57,7 @@ public class SpringImageView: UIImageView, Springable { self.spring.animate() } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } @@ -65,7 +65,7 @@ public class SpringImageView: UIImageView, Springable { self.spring.animateTo() } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } diff --git a/Spring/SpringLabel.swift b/Spring/SpringLabel.swift index ee16df3..1ebd526 100644 --- a/Spring/SpringLabel.swift +++ b/Spring/SpringLabel.swift @@ -57,7 +57,7 @@ public class SpringLabel: UILabel, Springable { self.spring.animate() } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } @@ -65,7 +65,7 @@ public class SpringLabel: UILabel, Springable { self.spring.animateTo() } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } diff --git a/Spring/SpringTextField.swift b/Spring/SpringTextField.swift index 1a0100b..7290e10 100644 --- a/Spring/SpringTextField.swift +++ b/Spring/SpringTextField.swift @@ -57,7 +57,7 @@ public class SpringTextField: UITextField, Springable { self.spring.animate() } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } @@ -65,7 +65,7 @@ public class SpringTextField: UITextField, Springable { self.spring.animateTo() } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } } diff --git a/Spring/SpringTextView.swift b/Spring/SpringTextView.swift index 651fb06..2ed4251 100644 --- a/Spring/SpringTextView.swift +++ b/Spring/SpringTextView.swift @@ -57,7 +57,7 @@ public class SpringTextView: UITextView, Springable { self.spring.animate() } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } @@ -65,7 +65,7 @@ public class SpringTextView: UITextView, Springable { self.spring.animateTo() } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } diff --git a/Spring/SpringView.swift b/Spring/SpringView.swift index 2ac0dac..c0e48a5 100644 --- a/Spring/SpringView.swift +++ b/Spring/SpringView.swift @@ -57,7 +57,7 @@ public class SpringView: UIView, Springable { self.spring.animate() } - public func animateNext(completion: () -> ()) { + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } @@ -65,7 +65,7 @@ public class SpringView: UIView, Springable { self.spring.animateTo() } - public func animateToNext(completion: () -> ()) { + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } } diff --git a/Spring/TransitionManager.swift b/Spring/TransitionManager.swift index 5cb1eff..388edac 100644 --- a/Spring/TransitionManager.swift +++ b/Spring/TransitionManager.swift @@ -29,8 +29,8 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { let container = transitionContext.containerView - let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! - let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! + let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)! + let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)! if isPresenting { toView.frame = container.bounds diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index 9dfb89a..6cf5301 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -29,8 +29,8 @@ public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UI public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { let container = transitionContext.containerView - let fromView = transitionContext.view(forKey: UITransitionContextFromViewKey)! - let toView = transitionContext.view(forKey: UITransitionContextToViewKey)! + let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)! + let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)! if isPresenting { container.addSubview(fromView) diff --git a/SpringApp/AppDelegate.swift b/SpringApp/AppDelegate.swift index a2ed126..fd03978 100644 --- a/SpringApp/AppDelegate.swift +++ b/SpringApp/AppDelegate.swift @@ -14,9 +14,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func applicationDidFinishLaunching(_ application: UIApplication) { // Override point for customization after application launch. - return true } func applicationWillResignActive(_ application: UIApplication) { diff --git a/SpringApp/SpringViewController.swift b/SpringApp/SpringViewController.swift index 7608843..1b53c11 100644 --- a/SpringApp/SpringViewController.swift +++ b/SpringApp/SpringViewController.swift @@ -260,7 +260,7 @@ class SpringViewController: UIViewController, UIPickerViewDelegate, UIPickerView } } - override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) { + override func prepare(for segue: UIStoryboardSegue, sender: Any?) { if let optionsViewController = segue.destination as? OptionsViewController { optionsViewController.delegate = self setOptions() From 7af3caed090fc0728555179385ad6e63925232a6 Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 14 Sep 2016 15:19:15 -0400 Subject: [PATCH 14/42] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e8fd104..cd07e95 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +![](https://dl.dropboxusercontent.com/u/7990919/Crawler/SpringSwift3.jpg) + ## Updated for Swift 3.0 Requires Xcode 8 and Swift 3. From 8bcb8c3d90ea2bdd1e6c3049cbd2ed411f4d82e0 Mon Sep 17 00:00:00 2001 From: Sam Rowley Date: Thu, 15 Sep 2016 17:11:58 +0100 Subject: [PATCH 15/42] Updated Access Control to 'open' for SpringView derivatives --- Spring/SpringButton.swift | 6 +++--- Spring/SpringImageView.swift | 6 +++--- Spring/SpringLabel.swift | 6 +++--- Spring/SpringTextField.swift | 6 +++--- Spring/SpringTextView.swift | 6 +++--- Spring/SpringView.swift | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Spring/SpringButton.swift b/Spring/SpringButton.swift index a4d7e8f..92124ea 100644 --- a/Spring/SpringButton.swift +++ b/Spring/SpringButton.swift @@ -22,7 +22,7 @@ import UIKit -public class SpringButton: UIButton, Springable { +open class SpringButton: UIButton, Springable { @IBInspectable public var autostart: Bool = false @IBInspectable public var autohide: Bool = false @IBInspectable public var animation: String = "" @@ -43,12 +43,12 @@ public class SpringButton: UIButton, Springable { lazy private var spring : Spring = Spring(self) - override public func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - public override func layoutSubviews() { + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } diff --git a/Spring/SpringImageView.swift b/Spring/SpringImageView.swift index 1da8046..85ad61f 100644 --- a/Spring/SpringImageView.swift +++ b/Spring/SpringImageView.swift @@ -22,7 +22,7 @@ import UIKit -public class SpringImageView: UIImageView, Springable { +open class SpringImageView: UIImageView, Springable { @IBInspectable public var autostart: Bool = false @IBInspectable public var autohide: Bool = false @IBInspectable public var animation: String = "" @@ -43,12 +43,12 @@ public class SpringImageView: UIImageView, Springable { lazy private var spring : Spring = Spring(self) - override public func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - public override func layoutSubviews() { + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } diff --git a/Spring/SpringLabel.swift b/Spring/SpringLabel.swift index 1ebd526..c105a48 100644 --- a/Spring/SpringLabel.swift +++ b/Spring/SpringLabel.swift @@ -22,7 +22,7 @@ import UIKit -public class SpringLabel: UILabel, Springable { +open class SpringLabel: UILabel, Springable { @IBInspectable public var autostart: Bool = false @IBInspectable public var autohide: Bool = false @IBInspectable public var animation: String = "" @@ -43,12 +43,12 @@ public class SpringLabel: UILabel, Springable { lazy private var spring : Spring = Spring(self) - override public func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - public override func layoutSubviews() { + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } diff --git a/Spring/SpringTextField.swift b/Spring/SpringTextField.swift index 7290e10..966b6f7 100644 --- a/Spring/SpringTextField.swift +++ b/Spring/SpringTextField.swift @@ -22,7 +22,7 @@ import UIKit -public class SpringTextField: UITextField, Springable { +open class SpringTextField: UITextField, Springable { @IBInspectable public var autostart: Bool = false @IBInspectable public var autohide: Bool = false @IBInspectable public var animation: String = "" @@ -43,12 +43,12 @@ public class SpringTextField: UITextField, Springable { lazy private var spring : Spring = Spring(self) - override public func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - public override func layoutSubviews() { + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } diff --git a/Spring/SpringTextView.swift b/Spring/SpringTextView.swift index 2ed4251..55d4e4a 100644 --- a/Spring/SpringTextView.swift +++ b/Spring/SpringTextView.swift @@ -22,7 +22,7 @@ import UIKit -public class SpringTextView: UITextView, Springable { +open class SpringTextView: UITextView, Springable { @IBInspectable public var autostart: Bool = false @IBInspectable public var autohide: Bool = false @IBInspectable public var animation: String = "" @@ -43,12 +43,12 @@ public class SpringTextView: UITextView, Springable { lazy private var spring : Spring = Spring(self) - override public func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - public override func layoutSubviews() { + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } diff --git a/Spring/SpringView.swift b/Spring/SpringView.swift index c0e48a5..a00c12a 100644 --- a/Spring/SpringView.swift +++ b/Spring/SpringView.swift @@ -22,7 +22,7 @@ import UIKit -public class SpringView: UIView, Springable { +open class SpringView: UIView, Springable { @IBInspectable public var autostart: Bool = false @IBInspectable public var autohide: Bool = false @IBInspectable public var animation: String = "" @@ -43,12 +43,12 @@ public class SpringView: UIView, Springable { lazy private var spring : Spring = Spring(self) - override public func awakeFromNib() { + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - public override func layoutSubviews() { + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } From 14b6a65349bfcb0d746227e7188c813e7c41cf85 Mon Sep 17 00:00:00 2001 From: Meng To Date: Fri, 16 Sep 2016 18:18:03 -0400 Subject: [PATCH 16/42] Fix UnwindSegue for Xcode 8 --- Spring/UnwindSegue.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spring/UnwindSegue.swift b/Spring/UnwindSegue.swift index a9aae71..53a71cb 100644 --- a/Spring/UnwindSegue.swift +++ b/Spring/UnwindSegue.swift @@ -23,5 +23,5 @@ import UIKit public extension UIViewController { - @IBAction public func unwindToViewController (sender: UIStoryboardSegue){} -} \ No newline at end of file + @IBAction public func unwindToViewController (_ segue: UIStoryboardSegue){} +} From 6aa5196caf91358c39fdf2b4190aeeb423126fb2 Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 5 Oct 2016 16:08:44 -0400 Subject: [PATCH 17/42] Update Spring App constraints for Xcode 8 --- SpringApp/Base.lproj/Main.storyboard | 167 +++++++++++---------------- 1 file changed, 70 insertions(+), 97 deletions(-) diff --git a/SpringApp/Base.lproj/Main.storyboard b/SpringApp/Base.lproj/Main.storyboard index f734ed9..6528bfc 100644 --- a/SpringApp/Base.lproj/Main.storyboard +++ b/SpringApp/Base.lproj/Main.storyboard @@ -1,8 +1,16 @@ - - + + - + + + + + + AvenirNext-DemiBold + AvenirNext-Regular + + @@ -13,15 +21,13 @@ - + - - - + @@ -35,32 +41,29 @@ - + @@ -130,67 +132,58 @@ - - - - + - - - + + - - - + + - - + - - + + - + @@ -210,7 +203,7 @@ - + @@ -256,40 +249,35 @@ - + - - - - + + - - + - + @@ -309,7 +297,7 @@ - + @@ -339,145 +327,130 @@ - + - - - - + + - - - + + - - - + + - - - + + - - - + + - - - + + - - + @@ -531,7 +504,7 @@ - + From ce0b195cb0be5b1fb971bdd0d314c048b6d33bca Mon Sep 17 00:00:00 2001 From: Meng To Date: Fri, 7 Oct 2016 17:45:07 -0400 Subject: [PATCH 18/42] Async Image Loader Extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, AsyncImageView and AsyncButton aren’t working, so I suggest that you use this Async UIImageView extension as an alternative until we figure out a solution. Would love help on those. --- Spring/Misc.swift | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 95cb32b..234f268 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -232,3 +232,31 @@ public func timeAgoSinceDate(date: Date, numericDates: Bool) -> String { } } + +extension UIImageView { + func setImage(url: URL, contentMode mode: UIViewContentMode = .scaleAspectFit, placeholderImage: UIImage?) { + contentMode = mode + URLSession.shared.dataTask(with: url) { (data, response, error) in + guard + let httpURLResponse = response as? HTTPURLResponse, httpURLResponse.statusCode == 200, + let mimeType = response?.mimeType, mimeType.hasPrefix("image"), + let data = data, error == nil, + let image = UIImage(data: data) + else { + self.image = placeholderImage + return + } + DispatchQueue.main.async() { () -> Void in + self.image = image + + } + }.resume() + } + func setImage(urlString: String, contentMode mode: UIViewContentMode = .scaleAspectFit, placeholderImage: UIImage?) { + guard let url = URL(string: urlString) else { + image = placeholderImage + return + } + setImage(url: url, contentMode: mode, placeholderImage: placeholderImage) + } +} From 9ee8ddbc001929f09c06c23d18f1c5be9e7256cb Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Sun, 9 Oct 2016 13:13:36 -0400 Subject: [PATCH 19/42] Fix issue in AsyncImageView and AsyncButton --- Spring/ImageLoader.swift | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index 263e1af..8fe470a 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -37,7 +37,19 @@ public class ImageLoader { public func imageForUrl(urlString: String, completionHandler: @escaping(_ image: UIImage?, _ url: String) -> ()) { DispatchQueue.global(qos: DispatchQoS.QoSClass.background).async { - let data: NSData? = self.cache.object(forKey: urlString as NSString)! as NSData + var data: NSData? + + if let dataCache = self.cache.object(forKey: urlString as NSString){ + data = (dataCache) as NSData + + }else{ + if (URL(string: urlString) != nil) + { + data = NSData(contentsOf: URL(string: urlString)!) + }else{ + return + } + } if let goodData = data { let image = UIImage(data: goodData as Data) From 95fff54cee89d24c9cfb83613fe2846dd99744c2 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Mon, 10 Oct 2016 20:54:24 -0400 Subject: [PATCH 20/42] Fix asynchronous image cache --- Spring/ImageLoader.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index 8fe470a..a5d8504 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -46,6 +46,7 @@ public class ImageLoader { if (URL(string: urlString) != nil) { data = NSData(contentsOf: URL(string: urlString)!) + self.cache.setObject(data!, forKey: urlString as NSString) }else{ return } From 0c5a350273ff7980be8cb9712a709b0e737ae169 Mon Sep 17 00:00:00 2001 From: sabyrzhan Date: Thu, 27 Oct 2016 16:49:14 +0600 Subject: [PATCH 21/42] Add check against nil before adding to cache --- Spring/ImageLoader.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index a5d8504..bcb626d 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -46,7 +46,9 @@ public class ImageLoader { if (URL(string: urlString) != nil) { data = NSData(contentsOf: URL(string: urlString)!) - self.cache.setObject(data!, forKey: urlString as NSString) + if data != nil { + self.cache.setObject(data!, forKey: urlString as NSString) + } }else{ return } From f502c5ecd673f22f75283e109eb0513fb80c1e86 Mon Sep 17 00:00:00 2001 From: shoheiyokoyama Date: Sun, 30 Oct 2016 18:21:32 +0900 Subject: [PATCH 22/42] fixed C-style syntax --- Spring/AutoTextView.swift | 2 +- Spring/DesignableTextField.swift | 4 ++-- Spring/DesignableTextView.swift | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Spring/AutoTextView.swift b/Spring/AutoTextView.swift index 9a0dfd3..1d0c7e6 100644 --- a/Spring/AutoTextView.swift +++ b/Spring/AutoTextView.swift @@ -18,7 +18,7 @@ public class AutoTextView: UITextView { size.height = 0 } - contentInset = UIEdgeInsetsMake(-4, -4, -4, -4) + contentInset = UIEdgeInsets(top: -4, left: -4, bottom: -4, right: -4) layoutIfNeeded() return size diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index 8cf32d0..ecaf442 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -89,8 +89,8 @@ import UIKit paragraphStyle.lineSpacing = lineHeight let attributedString = NSMutableAttributedString(string: text!) - attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) - attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSMakeRange(0, attributedString.length)) + attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSRange(location: 0, length: attributedString.length)) self.attributedText = attributedString } diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index 630941c..5a74fe1 100644 --- a/Spring/DesignableTextView.swift +++ b/Spring/DesignableTextView.swift @@ -49,10 +49,10 @@ import UIKit let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = lineHeight - + let attributedString = NSMutableAttributedString(string: text!) - attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) - attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSMakeRange(0, attributedString.length)) + attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSRange(location: 0, length: attributedString.length)) self.attributedText = attributedString } From a3d937f2afef44389094836a140c47d3de863516 Mon Sep 17 00:00:00 2001 From: Meng To Date: Tue, 4 Apr 2017 15:01:41 -0400 Subject: [PATCH 23/42] Xcode 8.3 update --- Spring/Misc.swift | 4 ++-- Spring/Spring.swift | 6 +++--- SpringApp.xcodeproj/project.pbxproj | 8 +++++++- .../xcshareddata/xcschemes/Spring.xcscheme | 2 +- .../xcshareddata/xcschemes/SpringApp.xcscheme | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 234f268..b6af7d5 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -43,7 +43,7 @@ public func htmlToAttributedString(text: String) -> NSAttributedString! { } public func degreesToRadians(degrees: CGFloat) -> CGFloat { - return degrees * CGFloat(M_PI / 180) + return degrees * CGFloat(CGFloat.pi / 180) } public func delay(delay:Double, closure: @escaping ()->()) { @@ -202,7 +202,7 @@ public func timeAgoSinceDate(date: Date, numericDates: Bool) -> String { return "1w" } } else if (day >= 2) { - return "\(components.day)d" + return "\(components.day ?? 2)d" } else if (day >= 1){ if (numericDates){ return "1d" diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 46819b1..a6ffff0 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -227,7 +227,7 @@ public class Spring : NSObject { scaleY = 2*force case .Fall: animateFrom = false - rotate = 15 * CGFloat(M_PI/180) + rotate = 15 * CGFloat(CGFloat.pi/180) y = 600*force case .Shake: let animation = CAKeyframeAnimation() @@ -262,7 +262,7 @@ public class Spring : NSObject { animation.keyPath = "transform" animation.fromValue = NSValue(caTransform3D: CATransform3DMakeRotation(0, 0, 0, 0)) animation.toValue = NSValue(caTransform3D: - CATransform3DConcat(perspective, CATransform3DMakeRotation(CGFloat(M_PI), 0, 1, 0))) + CATransform3DConcat(perspective, CATransform3DMakeRotation(CGFloat(CGFloat.pi), 0, 1, 0))) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) animation.timingFunction = getTimingFunction(curve: curve) @@ -276,7 +276,7 @@ public class Spring : NSObject { animation.fromValue = NSValue(caTransform3D: CATransform3DMakeRotation(0, 0, 0, 0)) animation.toValue = NSValue(caTransform3D: - CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(M_PI), 1, 0, 0))) + CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(CGFloat.pi), 1, 0, 0))) animation.duration = CFTimeInterval(duration) animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) animation.timingFunction = getTimingFunction(curve: curve) diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index 69ef340..bf9efd0 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -408,7 +408,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 0830; ORGANIZATIONNAME = "Meng To"; TargetAttributes = { 1A4FDA321A6E44780099D309 = { @@ -598,6 +598,7 @@ 1A4FDA4D1A6E44780099D309 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -624,6 +625,7 @@ 1A4FDA4E1A6E44780099D309 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; CURRENT_PROJECT_VERSION = 1; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -688,8 +690,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -732,8 +736,10 @@ 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_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; diff --git a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme index 3748fca..39102c6 100644 --- a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme +++ b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme @@ -1,6 +1,6 @@ Date: Fri, 16 Jun 2017 14:14:36 -0400 Subject: [PATCH 24/42] Swift 4 --- Spring/DesignableLabel.swift | 4 +- Spring/DesignableTabBarController.swift | 6 +-- Spring/DesignableTextField.swift | 6 +-- Spring/DesignableTextView.swift | 4 +- Spring/KeyboardLayoutConstraint.swift | 4 +- Spring/Misc.swift | 5 +- Spring/Spring.swift | 2 +- SpringApp.xcodeproj/project.pbxproj | 48 ++++++++++++++----- .../xcshareddata/xcschemes/Spring.xcscheme | 2 +- .../xcshareddata/xcschemes/SpringApp.xcscheme | 2 +- SpringApp/CodeViewController.swift | 2 + SpringApp/SpringViewController.swift | 4 +- 12 files changed, 57 insertions(+), 32 deletions(-) diff --git a/Spring/DesignableLabel.swift b/Spring/DesignableLabel.swift index 146174b..c232f69 100644 --- a/Spring/DesignableLabel.swift +++ b/Spring/DesignableLabel.swift @@ -33,8 +33,8 @@ import UIKit paragraphStyle.lineSpacing = lineHeight let attributedString = NSMutableAttributedString(string: text!) - attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) - attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSMakeRange(0, attributedString.length)) + attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) + attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSMakeRange(0, attributedString.length)) self.attributedText = attributedString } diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index 4e55cfc..0857e87 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -27,20 +27,20 @@ import UIKit @IBInspectable var normalTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = normalTint - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint], for: UIControlState()) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: normalTint], for: UIControlState()) } } @IBInspectable var selectedTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = selectedTint - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: selectedTint], for:UIControlState.selected) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: selectedTint], for:UIControlState.selected) } } @IBInspectable var fontName: String = "" { didSet { - UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: normalTint, NSFontAttributeName: UIFont(name: fontName, size: 11)!], for: UIControlState()) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: normalTint, NSAttributedStringKey.font.rawValue: UIFont(name: fontName, size: 11)!], for: UIControlState()) } } diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index ecaf442..8be2717 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -26,7 +26,7 @@ import UIKit @IBInspectable public var placeholderColor: UIColor = UIColor.clear { didSet { - attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSForegroundColorAttributeName: placeholderColor]) + attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor]) layoutSubviews() } @@ -89,8 +89,8 @@ import UIKit paragraphStyle.lineSpacing = lineHeight let attributedString = NSMutableAttributedString(string: text!) - attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) - attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) self.attributedText = attributedString } diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index 5a74fe1..e716b96 100644 --- a/Spring/DesignableTextView.swift +++ b/Spring/DesignableTextView.swift @@ -51,8 +51,8 @@ import UIKit paragraphStyle.lineSpacing = lineHeight let attributedString = NSMutableAttributedString(string: text!) - attributedString.addAttribute(NSParagraphStyleAttributeName, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) - attributedString.addAttribute(NSFontAttributeName, value: font!, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) self.attributedText = attributedString } diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 57ef6f8..79dc8cb 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -42,7 +42,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { // MARK: Notification - func keyboardWillShowNotification(_ notification: Notification) { + @objc func keyboardWillShowNotification(_ notification: Notification) { if let userInfo = notification.userInfo { if let frameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue { let frame = frameValue.cgRectValue @@ -73,7 +73,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { } - func keyboardWillHideNotification(_ notification: NSNotification) { + @objc func keyboardWillHideNotification(_ notification: NSNotification) { keyboardVisibleHeight = 0 self.updateConstant() diff --git a/Spring/Misc.swift b/Spring/Misc.swift index b6af7d5..2a80c01 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -31,10 +31,11 @@ public extension String { } public func htmlToAttributedString(text: String) -> NSAttributedString! { - let htmlData = text.data(using: String.Encoding.utf8, allowLossyConversion: false) + guard let htmlData = text.data(using: String.Encoding.utf8, allowLossyConversion: false) else { + return NSAttributedString() } let htmlString: NSAttributedString? do { - htmlString = try NSAttributedString(data: htmlData!, options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) + htmlString = try NSAttributedString(data: htmlData, options: [NSAttributedString.DocumentReadingOptionKey.documentType:NSAttributedString.DocumentType.html], documentAttributes: nil) } catch _ { htmlString = nil } diff --git a/Spring/Spring.swift b/Spring/Spring.swift index a6ffff0..5b60b1b 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -68,7 +68,7 @@ public class Spring : NSObject { NotificationCenter.default.addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) } - func didBecomeActiveNotification(_ notification: NSNotification) { + @objc func didBecomeActiveNotification(_ notification: NSNotification) { if shouldAnimateAfterActive { alpha = 0 animate() diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index bf9efd0..008a95a 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -408,25 +408,25 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = "Meng To"; TargetAttributes = { 1A4FDA321A6E44780099D309 = { CreatedOnToolsVersion = 6.1.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 1A4FDA3C1A6E44780099D309 = { CreatedOnToolsVersion = 6.1.1; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 9641173A1A5BE90A000E3A5A; }; 9641173A1A5BE90A000E3A5A = { CreatedOnToolsVersion = 6.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; }; 9641174F1A5BE90A000E3A5A = { CreatedOnToolsVersion = 6.2; - LastSwiftMigration = 0800; + LastSwiftMigration = 0900; TestTargetID = 9641173A1A5BE90A000E3A5A; }; }; @@ -615,7 +615,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -639,7 +640,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -658,7 +660,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Debug; @@ -672,7 +675,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; @@ -685,14 +689,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; @@ -720,6 +730,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; }; name = Debug; }; @@ -731,14 +742,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; @@ -757,6 +774,7 @@ IPHONEOS_DEPLOYMENT_TARGET = 8.2; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; VALIDATE_PRODUCT = YES; }; name = Release; @@ -770,7 +788,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -785,7 +804,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -802,7 +822,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Debug; @@ -816,7 +837,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; diff --git a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme index 39102c6..ecfaae8 100644 --- a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme +++ b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme @@ -1,6 +1,6 @@ Date: Mon, 19 Jun 2017 11:37:17 -0400 Subject: [PATCH 25/42] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index cd07e95..278fa38 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ -![](https://dl.dropboxusercontent.com/u/7990919/Crawler/SpringSwift3.jpg) - -## Updated for Swift 3.0 -Requires Xcode 8 and Swift 3. +## Updated for Swift 4 +Requires Xcode 9 and Swift 4. ## Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups"). From 4bc88153e711f77d1a543bac6abdbc064e304692 Mon Sep 17 00:00:00 2001 From: JPwharton Date: Wed, 28 Jun 2017 09:35:37 -0400 Subject: [PATCH 26/42] Quick fix to placeHolder crash, removal of bang operator. --- Spring/DesignableTextField.swift | 7 ++++--- Spring/DesignableTextView.swift | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index 8be2717..edc5a2b 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -26,7 +26,8 @@ import UIKit @IBInspectable public var placeholderColor: UIColor = UIColor.clear { didSet { - attributedPlaceholder = NSAttributedString(string: placeholder!, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor]) + guard let placeholder = placeholder else { return } + attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor]) layoutSubviews() } @@ -83,12 +84,12 @@ import UIKit @IBInspectable public var lineHeight: CGFloat = 1.5 { didSet { let font = UIFont(name: self.font!.fontName, size: self.font!.pointSize) - let text = self.text + guard let text = self.text else { return } let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = lineHeight - let attributedString = NSMutableAttributedString(string: text!) + let attributedString = NSMutableAttributedString(string: text) attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index e716b96..3db40b3 100644 --- a/Spring/DesignableTextView.swift +++ b/Spring/DesignableTextView.swift @@ -45,12 +45,12 @@ import UIKit @IBInspectable public var lineHeight: CGFloat = 1.5 { didSet { let font = UIFont(name: self.font!.fontName, size: self.font!.pointSize) - let text = self.text + guard let text = self.text else { return } let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = lineHeight - let attributedString = NSMutableAttributedString(string: text!) + let attributedString = NSMutableAttributedString(string: text) attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) From 57e4b4fe97bc7a9010d30c03adaefea730f9989a Mon Sep 17 00:00:00 2001 From: JPwharton Date: Wed, 28 Jun 2017 09:44:05 -0400 Subject: [PATCH 27/42] Additional force unwrap fixes --- Spring/DesignableLabel.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spring/DesignableLabel.swift b/Spring/DesignableLabel.swift index c232f69..0520d77 100644 --- a/Spring/DesignableLabel.swift +++ b/Spring/DesignableLabel.swift @@ -27,12 +27,12 @@ import UIKit @IBInspectable public var lineHeight: CGFloat = 1.5 { didSet { let font = UIFont(name: self.font.fontName, size: self.font.pointSize) - let text = self.text + guard let text = self.text else { return } let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = lineHeight - let attributedString = NSMutableAttributedString(string: text!) + let attributedString = NSMutableAttributedString(string: text) attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSMakeRange(0, attributedString.length)) From 386804a3beabe27830ce506f44058c878c591622 Mon Sep 17 00:00:00 2001 From: Jonathan Pacheco Date: Sun, 2 Jul 2017 17:35:03 -0500 Subject: [PATCH 28/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 278fa38..8c84806 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Drop in the Spring folder to your Xcode project (make sure to enable "Copy items Or via CocoaPods: ``` use_frameworks! -pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift3' +pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift4' ``` ## Usage with Storyboard From fa94a8743211fb8c2dc9171ad6672095175ef405 Mon Sep 17 00:00:00 2001 From: Jake Manning Date: Tue, 11 Jul 2017 18:07:46 -0700 Subject: [PATCH 29/42] Update SoundPlayer.swift MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #217 details this problem. It isn’t possible to use SoundPlayer unless these are public --- Spring/SoundPlayer.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Spring/SoundPlayer.swift b/Spring/SoundPlayer.swift index 122ba42..d2451d9 100644 --- a/Spring/SoundPlayer.swift +++ b/Spring/SoundPlayer.swift @@ -23,7 +23,7 @@ import UIKit import AudioToolbox -struct SoundPlayer { +public struct SoundPlayer { static var filename : String? static var enabled : Bool = true @@ -32,7 +32,7 @@ struct SoundPlayer { static var cache = [URL:SystemSoundID]() } - static func playSound(soundFile: String) { + public static func playSound(soundFile: String) { if !enabled { return From 94b2f06c10a006805d7b797c01674ad73556c37e Mon Sep 17 00:00:00 2001 From: thedoritos Date: Tue, 1 Aug 2017 10:57:11 +0900 Subject: [PATCH 30/42] Fix compile error --- Spring/DesignableTabBarController.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index 0857e87..dc55036 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -27,20 +27,20 @@ import UIKit @IBInspectable var normalTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = normalTint - UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: normalTint], for: UIControlState()) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: normalTint], for: UIControlState()) } } @IBInspectable var selectedTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = selectedTint - UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: selectedTint], for:UIControlState.selected) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: selectedTint], for:UIControlState.selected) } } @IBInspectable var fontName: String = "" { didSet { - UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor.rawValue: normalTint, NSAttributedStringKey.font.rawValue: UIFont(name: fontName, size: 11)!], for: UIControlState()) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: normalTint, NSAttributedStringKey.font: UIFont(name: fontName, size: 11)!], for: UIControlState()) } } From ed10baac4fecd152882a2d301b45a2769c1240c7 Mon Sep 17 00:00:00 2001 From: Hamza Ansari Date: Fri, 20 Oct 2017 14:16:21 +0530 Subject: [PATCH 31/42] Substring deprecated fix --- Spring/Misc.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 2a80c01..b2a27ce 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -67,7 +67,7 @@ public extension UIColor { if hex.hasPrefix("#") { let index = hex.index(hex.startIndex, offsetBy: 1) - hex = hex.substring(from: index) + hex = String(hex[index...]) } let scanner = Scanner(string: hex) From 803a87ed53c942e5dfb1af8b77e3e68850d742d9 Mon Sep 17 00:00:00 2001 From: Tony Mann Date: Sun, 8 Jan 2017 14:41:45 -0800 Subject: [PATCH 32/42] Fix repeat count in the swing animation --- Spring/Spring.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Spring/Spring.swift b/Spring/Spring.swift index 5b60b1b..a563044 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -358,6 +358,7 @@ public class Spring : NSObject { animation.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] animation.duration = CFTimeInterval(duration) animation.isAdditive = true + animation.repeatCount = repeatCount animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(animation, forKey: "swing") } From 18b1dbc8a8b346b179413c77fa96f5cb0f78624f Mon Sep 17 00:00:00 2001 From: phatmann Date: Tue, 31 Oct 2017 22:22:06 -0700 Subject: [PATCH 33/42] Use master branch for pod --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c84806..0209267 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Drop in the Spring folder to your Xcode project (make sure to enable "Copy items Or via CocoaPods: ``` use_frameworks! -pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift4' +pod 'Spring', :git => 'https://github.com/MengTo/Spring.git' ``` ## Usage with Storyboard From df1ecb65322254f36430c02b632e4724d9cdf720 Mon Sep 17 00:00:00 2001 From: Iori Kanno Date: Wed, 15 Nov 2017 03:11:07 +0900 Subject: [PATCH 34/42] Fix repeat count in the flip animation --- Spring/Spring.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Spring/Spring.swift b/Spring/Spring.swift index a563044..ed2808b 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -264,6 +264,7 @@ public class Spring : NSObject { animation.toValue = NSValue(caTransform3D: CATransform3DConcat(perspective, CATransform3DMakeRotation(CGFloat(CGFloat.pi), 0, 1, 0))) animation.duration = CFTimeInterval(duration) + animation.repeatCount = repeatCount animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) animation.timingFunction = getTimingFunction(curve: curve) layer.add(animation, forKey: "3d") @@ -278,6 +279,7 @@ public class Spring : NSObject { animation.toValue = NSValue(caTransform3D: CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(CGFloat.pi), 1, 0, 0))) animation.duration = CFTimeInterval(duration) + animation.repeatCount = repeatCount animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) animation.timingFunction = getTimingFunction(curve: curve) layer.add(animation, forKey: "3d") From be6285482de439bf768f6ebf20c8899aa0c5a57c Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 20 Dec 2017 15:20:28 -0500 Subject: [PATCH 35/42] cocoapods 1.0.4 with Swift 4 --- .swift-version | 1 + Spring.podspec | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 .swift-version diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..b8626c4 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +4 diff --git a/Spring.podspec b/Spring.podspec index a381019..cf59266 100644 --- a/Spring.podspec +++ b/Spring.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Spring' - s.version = '1.0.3' + s.version = '1.0.4' s.license = 'MIT' s.summary = 'A library to simplify iOS animations in Swift.' s.homepage = 'https://github.com/MengTo/Spring' From 19b04d730d3edabbb02a39e58121d1d3220690ee Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 20 Dec 2017 15:21:26 -0500 Subject: [PATCH 36/42] Podspec 1.0.5 Swift 4 --- Spring.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spring.podspec b/Spring.podspec index cf59266..6176a50 100644 --- a/Spring.podspec +++ b/Spring.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Spring' - s.version = '1.0.4' + s.version = '1.0.5' s.license = 'MIT' s.summary = 'A library to simplify iOS animations in Swift.' s.homepage = 'https://github.com/MengTo/Spring' From 9a9148948446786caf12ae0158d15116a3229ed0 Mon Sep 17 00:00:00 2001 From: Larry Aasen Date: Sun, 31 Dec 2017 10:23:58 -0500 Subject: [PATCH 37/42] Added support for tvOS. Updated podspec file for tvOS. Eliminated class KeyboardLayoutConstraint on tvOS. Eliminated class LoadingView on tvOS. --- Spring.podspec | 4 +++- Spring/KeyboardLayoutConstraint.swift | 4 ++++ Spring/LoadingView.swift | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Spring.podspec b/Spring.podspec index 6176a50..b05c6ee 100644 --- a/Spring.podspec +++ b/Spring.podspec @@ -8,6 +8,8 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/MengTo/Spring.git', :tag => s.version.to_s } s.requires_arc = true s.ios.deployment_target = '8.0' + s.tvos.deployment_target = '11.0' s.source_files = 'Spring/*.swift' - s.resources = ['Spring/*.xib', 'SpringApp/*.xcassets'] + s.ios.resources = ['Spring/*.xib', 'SpringApp/*.xcassets'] + s.tvos.resources = ['SpringApp/*.xcassets'] end diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 79dc8cb..7d1cf9c 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -22,11 +22,14 @@ import UIKit +#if !os(tvOS) +@available(tvOS, unavailable) public class KeyboardLayoutConstraint: NSLayoutConstraint { private var offset : CGFloat = 0 private var keyboardVisibleHeight : CGFloat = 0 + @available(tvOS, unavailable) override public func awakeFromNib() { super.awakeFromNib() @@ -104,3 +107,4 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { } } +#endif diff --git a/Spring/LoadingView.swift b/Spring/LoadingView.swift index 047aaa9..5f62ce8 100644 --- a/Spring/LoadingView.swift +++ b/Spring/LoadingView.swift @@ -22,6 +22,8 @@ import UIKit +#if !os(tvOS) +@available(tvOS, unavailable) public class LoadingView: UIView { @IBOutlet public weak var indicatorView: SpringView! @@ -81,3 +83,4 @@ public extension UIView { } } +#endif From dc55d6dfc8a4bb4fbe3fd683644d363deb4ad749 Mon Sep 17 00:00:00 2001 From: Juan Carbonell Date: Fri, 21 Sep 2018 11:07:05 +0200 Subject: [PATCH 38/42] FIX Updated for Xcode 10 and Swift 4.2 --- Spring/AsyncButton.swift | 2 +- Spring/BlurView.swift | 2 +- Spring/DesignableLabel.swift | 4 ++-- Spring/DesignableTabBarController.swift | 18 ++++++++-------- Spring/DesignableTextField.swift | 14 ++++++------- Spring/DesignableTextView.swift | 10 ++++----- Spring/KeyboardLayoutConstraint.swift | 14 ++++++------- Spring/Misc.swift | 4 ++-- Spring/Spring.swift | 28 ++++++++++++------------- Spring/SpringAnimation.swift | 2 +- SpringApp.xcodeproj/project.pbxproj | 8 +++---- 11 files changed, 53 insertions(+), 53 deletions(-) diff --git a/Spring/AsyncButton.swift b/Spring/AsyncButton.swift index 7d9f2db..6e03ac9 100644 --- a/Spring/AsyncButton.swift +++ b/Spring/AsyncButton.swift @@ -28,7 +28,7 @@ public class AsyncButton: UIButton { private var placeholderImage = [UInt:UIImage]() - public func setImageURL(url: NSURL?, placeholderImage placeholder:UIImage?, forState state:UIControlState) { + public func setImageURL(url: NSURL?, placeholderImage placeholder:UIImage?, forState state:UIControl.State) { imageURL[state.rawValue] = url placeholderImage[state.rawValue] = placeholder diff --git a/Spring/BlurView.swift b/Spring/BlurView.swift index 2defcf6..8de1611 100644 --- a/Spring/BlurView.swift +++ b/Spring/BlurView.swift @@ -22,7 +22,7 @@ import UIKit -public func insertBlurView (view: UIView, style: UIBlurEffectStyle) -> UIVisualEffectView { +public func insertBlurView (view: UIView, style: UIBlurEffect.Style) -> UIVisualEffectView { view.backgroundColor = UIColor.clear let blurEffect = UIBlurEffect(style: style) diff --git a/Spring/DesignableLabel.swift b/Spring/DesignableLabel.swift index 0520d77..8d6994b 100644 --- a/Spring/DesignableLabel.swift +++ b/Spring/DesignableLabel.swift @@ -33,8 +33,8 @@ import UIKit paragraphStyle.lineSpacing = lineHeight let attributedString = NSMutableAttributedString(string: text) - attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) - attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSMakeRange(0, attributedString.length)) + attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSMakeRange(0, attributedString.length)) + attributedString.addAttribute(NSAttributedString.Key.font, value: font!, range: NSMakeRange(0, attributedString.length)) self.attributedText = attributedString } diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index dc55036..f75fbcc 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -27,20 +27,20 @@ import UIKit @IBInspectable var normalTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = normalTint - UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: normalTint], for: UIControlState()) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: normalTint], for: UIControl.State()) } } @IBInspectable var selectedTint: UIColor = UIColor.clear { didSet { UITabBar.appearance().tintColor = selectedTint - UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: selectedTint], for:UIControlState.selected) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: selectedTint], for:UIControl.State.selected) } } @IBInspectable var fontName: String = "" { didSet { - UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: normalTint, NSAttributedStringKey.font: UIFont(name: fontName, size: 11)!], for: UIControlState()) + UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: normalTint, NSAttributedString.Key.font: UIFont(name: fontName, size: 11)!], for: UIControl.State()) } } @@ -48,7 +48,7 @@ import UIKit didSet { if let image = firstSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems?[0].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) + tabBarItems?[0].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } } @@ -57,7 +57,7 @@ import UIKit didSet { if let image = secondSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems?[1].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) + tabBarItems?[1].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } } @@ -66,7 +66,7 @@ import UIKit didSet { if let image = thirdSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems?[2].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) + tabBarItems?[2].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } } @@ -75,7 +75,7 @@ import UIKit didSet { if let image = fourthSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems?[3].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) + tabBarItems?[3].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } } @@ -84,7 +84,7 @@ import UIKit didSet { if let image = fifthSelectedImage { var tabBarItems = self.tabBar.items as [UITabBarItem]! - tabBarItems?[4].selectedImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) + tabBarItems?[4].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } } @@ -94,7 +94,7 @@ import UIKit for item in self.tabBar.items as [UITabBarItem]! { if let image = item.image { - item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImageRenderingMode.alwaysOriginal) + item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImage.RenderingMode.alwaysOriginal) } } } diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index edc5a2b..e334a8e 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -27,7 +27,7 @@ import UIKit @IBInspectable public var placeholderColor: UIColor = UIColor.clear { didSet { guard let placeholder = placeholder else { return } - attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedStringKey.foregroundColor: placeholderColor]) + attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor: placeholderColor]) layoutSubviews() } @@ -37,10 +37,10 @@ import UIKit didSet { let padding = UIView(frame: CGRect(x: 0, y: 0, width: sidePadding, height: sidePadding)) - leftViewMode = UITextFieldViewMode.always + leftViewMode = UITextField.ViewMode.always leftView = padding - rightViewMode = UITextFieldViewMode.always + rightViewMode = UITextField.ViewMode.always rightView = padding } } @@ -49,7 +49,7 @@ import UIKit didSet { let padding = UIView(frame: CGRect(x: 0, y: 0, width: leftPadding, height: 0)) - leftViewMode = UITextFieldViewMode.always + leftViewMode = UITextField.ViewMode.always leftView = padding } } @@ -58,7 +58,7 @@ import UIKit didSet { let padding = UIView(frame: CGRect(x: 0, y: 0, width: rightPadding, height: 0)) - rightViewMode = UITextFieldViewMode.always + rightViewMode = UITextField.ViewMode.always rightView = padding } } @@ -90,8 +90,8 @@ import UIKit paragraphStyle.lineSpacing = lineHeight let attributedString = NSMutableAttributedString(string: text) - attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) - attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedString.Key.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) self.attributedText = attributedString } diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index 3db40b3..779298a 100644 --- a/Spring/DesignableTextView.swift +++ b/Spring/DesignableTextView.swift @@ -41,7 +41,7 @@ import UIKit layer.cornerRadius = cornerRadius } } - + @IBInspectable public var lineHeight: CGFloat = 1.5 { didSet { let font = UIFont(name: self.font!.fontName, size: self.font!.pointSize) @@ -49,13 +49,13 @@ import UIKit let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.lineSpacing = lineHeight - + let attributedString = NSMutableAttributedString(string: text) - attributedString.addAttribute(NSAttributedStringKey.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) - attributedString.addAttribute(NSAttributedStringKey.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedString.Key.paragraphStyle, value: paragraphStyle, range: NSRange(location: 0, length: attributedString.length)) + attributedString.addAttribute(NSAttributedString.Key.font, value: font!, range: NSRange(location: 0, length: attributedString.length)) self.attributedText = attributedString } } - + } diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 7d1cf9c..1b45a56 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -35,8 +35,8 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { offset = constant - NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: NSNotification.Name.UIKeyboardWillHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillShowNotification(_:)), name: UIWindow.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(KeyboardLayoutConstraint.keyboardWillHideNotification(_:)), name: UIWindow.keyboardWillHideNotification, object: nil) } deinit { @@ -47,16 +47,16 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { @objc func keyboardWillShowNotification(_ notification: Notification) { if let userInfo = notification.userInfo { - if let frameValue = userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue { + if let frameValue = userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue { let frame = frameValue.cgRectValue keyboardVisibleHeight = frame.size.height } self.updateConstant() - switch (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber) { + switch (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber) { case let (.some(duration), .some(curve)): - let options = UIViewAnimationOptions(rawValue: curve.uintValue) + let options = UIView.AnimationOptions(rawValue: curve.uintValue) UIView.animate( withDuration: TimeInterval(duration.doubleValue), @@ -82,10 +82,10 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { if let userInfo = notification.userInfo { - switch (userInfo[UIKeyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIKeyboardAnimationCurveUserInfoKey] as? NSNumber) { + switch (userInfo[UIResponder.keyboardAnimationDurationUserInfoKey] as? NSNumber, userInfo[UIResponder.keyboardAnimationCurveUserInfoKey] as? NSNumber) { case let (.some(duration), .some(curve)): - let options = UIViewAnimationOptions(rawValue: curve.uintValue) + let options = UIView.AnimationOptions(rawValue: curve.uintValue) UIView.animate( withDuration: TimeInterval(duration.doubleValue), diff --git a/Spring/Misc.swift b/Spring/Misc.swift index b2a27ce..c0a9add 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -235,7 +235,7 @@ public func timeAgoSinceDate(date: Date, numericDates: Bool) -> String { } extension UIImageView { - func setImage(url: URL, contentMode mode: UIViewContentMode = .scaleAspectFit, placeholderImage: UIImage?) { + func setImage(url: URL, contentMode mode: UIView.ContentMode = .scaleAspectFit, placeholderImage: UIImage?) { contentMode = mode URLSession.shared.dataTask(with: url) { (data, response, error) in guard @@ -253,7 +253,7 @@ extension UIImageView { } }.resume() } - func setImage(urlString: String, contentMode mode: UIViewContentMode = .scaleAspectFit, placeholderImage: UIImage?) { + func setImage(urlString: String, contentMode mode: UIView.ContentMode = .scaleAspectFit, placeholderImage: UIImage?) { guard let url = URL(string: urlString) else { image = placeholderImage return diff --git a/Spring/Spring.swift b/Spring/Spring.swift index ed2808b..cf86e1a 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -65,7 +65,7 @@ public class Spring : NSObject { } func commonInit() { - NotificationCenter.default.addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(Spring.didBecomeActiveNotification(_:)), name: UIApplication.didBecomeActiveNotification, object: nil) } @objc func didBecomeActiveNotification(_ notification: NSNotification) { @@ -77,7 +77,7 @@ public class Spring : NSObject { } deinit { - NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIApplicationDidBecomeActive, object: nil) + NotificationCenter.default.removeObserver(self, name: UIApplication.didBecomeActiveNotification, object: nil) } private var autostart: Bool { set { self.view.autostart = newValue } get { return self.view.autostart }} @@ -370,10 +370,10 @@ public class Spring : NSObject { func getTimingFunction(curve: String) -> CAMediaTimingFunction { if let curve = AnimationCurve(rawValue: curve) { switch curve { - case .EaseIn: return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn) - case .EaseOut: return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) - case .EaseInOut: return CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut) - case .Linear: return CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear) + case .EaseIn: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeIn) + case .EaseOut: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeOut) + case .EaseInOut: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.easeInEaseOut) + case .Linear: return CAMediaTimingFunction(name: CAMediaTimingFunctionName.linear) case .Spring: return CAMediaTimingFunction(controlPoints: 0.5, 1.1+Float(force/3), 1, 1) case .EaseInSine: return CAMediaTimingFunction(controlPoints: 0.47, 0, 0.745, 0.715) case .EaseOutSine: return CAMediaTimingFunction(controlPoints: 0.39, 0.575, 0.565, 1) @@ -401,19 +401,19 @@ public class Spring : NSObject { case .EaseInOutBack: return CAMediaTimingFunction(controlPoints: 0.68, -0.55, 0.265, 1.55) } } - return CAMediaTimingFunction(name: kCAMediaTimingFunctionDefault) + return CAMediaTimingFunction(name: CAMediaTimingFunctionName.default) } - func getAnimationOptions(curve: String) -> UIViewAnimationOptions { + func getAnimationOptions(curve: String) -> UIView.AnimationOptions { if let curve = AnimationCurve(rawValue: curve) { switch curve { - case .EaseIn: return UIViewAnimationOptions.curveEaseIn - case .EaseOut: return UIViewAnimationOptions.curveEaseOut - case .EaseInOut: return UIViewAnimationOptions() + case .EaseIn: return UIView.AnimationOptions.curveEaseIn + case .EaseOut: return UIView.AnimationOptions.curveEaseOut + case .EaseInOut: return UIView.AnimationOptions() default: break } } - return UIViewAnimationOptions.curveLinear + return UIView.AnimationOptions.curveLinear } public func animate() { @@ -479,7 +479,7 @@ public class Spring : NSObject { delay: TimeInterval(delay), usingSpringWithDamping: damping, initialSpringVelocity: velocity, - options: [getAnimationOptions(curve: curve), UIViewAnimationOptions.allowUserInteraction], + options: [getAnimationOptions(curve: curve), UIView.AnimationOptions.allowUserInteraction], animations: { [weak self] in if let _self = self { @@ -504,7 +504,7 @@ public class Spring : NSObject { completion() self?.resetAll() - }) + }) } diff --git a/Spring/SpringAnimation.swift b/Spring/SpringAnimation.swift index e237d3d..998882b 100644 --- a/Spring/SpringAnimation.swift +++ b/Spring/SpringAnimation.swift @@ -64,7 +64,7 @@ import UIKit UIView.animate( withDuration: duration, delay: 0, - options: UIViewAnimationOptions(), + options: UIView.AnimationOptions(), animations: { animations() }, completion: nil diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index 008a95a..8e701c1 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -616,7 +616,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -641,7 +641,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -789,7 +789,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -805,7 +805,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; From d761f575b0bd593c57718b53125908d9258ddc08 Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 3 Oct 2018 11:16:39 -0400 Subject: [PATCH 39/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0209267..49a7fa5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ ## Updated for Swift 4 -Requires Xcode 9 and Swift 4. +Requires Xcode 10 and Swift 4.2. ## Installation Drop in the Spring folder to your Xcode project (make sure to enable "Copy items if needed" and "Create groups"). From d507c1244f944dcf675aa46fe024e2b2f40a662c Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 3 Oct 2018 11:16:48 -0400 Subject: [PATCH 40/42] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49a7fa5..34f1430 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -## Updated for Swift 4 +## Updated for Swift 4.2 Requires Xcode 10 and Swift 4.2. ## Installation From fafd0b2e8d4d46405bd86fa7ba84bb7f73a20b13 Mon Sep 17 00:00:00 2001 From: Meng To Date: Wed, 10 Oct 2018 13:23:42 -0400 Subject: [PATCH 41/42] Update Spring.podspec --- Spring.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Spring.podspec b/Spring.podspec index b05c6ee..a43ed30 100644 --- a/Spring.podspec +++ b/Spring.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Spring' - s.version = '1.0.5' + s.version = '1.0.6' s.license = 'MIT' s.summary = 'A library to simplify iOS animations in Swift.' s.homepage = 'https://github.com/MengTo/Spring' From febc1fa3787b19f8dc21c48d5e7bb826ef46bb25 Mon Sep 17 00:00:00 2001 From: nhannlt Date: Fri, 26 Jul 2019 15:29:03 +0700 Subject: [PATCH 42/42] Upgrade to swift 5 --- Spring/DesignableTabBarController.swift | 19 +++++++------- Spring/Misc.swift | 6 ++--- SpringApp.xcodeproj/project.pbxproj | 33 ++++++++++--------------- 3 files changed, 26 insertions(+), 32 deletions(-) diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index f75fbcc..6c81095 100644 --- a/Spring/DesignableTabBarController.swift +++ b/Spring/DesignableTabBarController.swift @@ -47,7 +47,7 @@ import UIKit @IBInspectable var firstSelectedImage: UIImage? { didSet { if let image = firstSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[0].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } @@ -56,7 +56,7 @@ import UIKit @IBInspectable var secondSelectedImage: UIImage? { didSet { if let image = secondSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[1].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } @@ -65,7 +65,7 @@ import UIKit @IBInspectable var thirdSelectedImage: UIImage? { didSet { if let image = thirdSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[2].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } @@ -74,7 +74,7 @@ import UIKit @IBInspectable var fourthSelectedImage: UIImage? { didSet { if let image = fourthSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[3].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } @@ -83,7 +83,7 @@ import UIKit @IBInspectable var fifthSelectedImage: UIImage? { didSet { if let image = fifthSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]! + var tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[4].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } @@ -91,10 +91,11 @@ import UIKit override func viewDidLoad() { super.viewDidLoad() - - for item in self.tabBar.items as [UITabBarItem]! { - if let image = item.image { - item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImage.RenderingMode.alwaysOriginal) + if let items = self.tabBar.items { + for item in items { + if let image = item.image { + item.image = image.imageWithColor(tintColor: self.normalTint).withRenderingMode(UIImage.RenderingMode.alwaysOriginal) + } } } } diff --git a/Spring/Misc.swift b/Spring/Misc.swift index c0a9add..96024b8 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -23,9 +23,9 @@ import UIKit public extension String { - public var length: Int { return self.characters.count } + var length: Int { return self.count } - public func toURL() -> NSURL? { + func toURL() -> NSURL? { return NSURL(string: self) } } @@ -73,7 +73,7 @@ public extension UIColor { let scanner = Scanner(string: hex) var hexValue: CUnsignedLongLong = 0 if scanner.scanHexInt64(&hexValue) { - switch (hex.characters.count) { + switch (hex.count) { case 3: red = CGFloat((hexValue & 0xF00) >> 8) / 15.0 green = CGFloat((hexValue & 0x0F0) >> 4) / 15.0 diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index 8e701c1..a0e8956 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -413,20 +413,20 @@ TargetAttributes = { 1A4FDA321A6E44780099D309 = { CreatedOnToolsVersion = 6.1.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; 1A4FDA3C1A6E44780099D309 = { CreatedOnToolsVersion = 6.1.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; TestTargetID = 9641173A1A5BE90A000E3A5A; }; 9641173A1A5BE90A000E3A5A = { CreatedOnToolsVersion = 6.2; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; 9641174F1A5BE90A000E3A5A = { CreatedOnToolsVersion = 6.2; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; TestTargetID = 9641173A1A5BE90A000E3A5A; }; }; @@ -436,6 +436,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -615,8 +616,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -640,8 +640,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -660,8 +659,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Debug; @@ -675,8 +673,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release; @@ -788,8 +785,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -804,8 +800,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -822,8 +817,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Debug; @@ -837,8 +831,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpringApp.app/SpringApp"; }; name = Release;