diff --git a/Spring/AsyncButton.swift b/Spring/AsyncButton.swift index 6e03ac9..75e262e 100644 --- a/Spring/AsyncButton.swift +++ b/Spring/AsyncButton.swift @@ -24,11 +24,10 @@ import UIKit public class AsyncButton: UIButton { - private var imageURL = [UInt:NSURL]() - private var placeholderImage = [UInt:UIImage]() + private var imageURL = [UInt: NSURL]() + private var placeholderImage = [UInt: UIImage]() - - public func setImageURL(url: NSURL?, placeholderImage placeholder:UIImage?, forState state:UIControl.State) { + public func setImageURL(url: NSURL?, placeholderImage placeholder: UIImage?, forState state: UIControl.State) { imageURL[state.rawValue] = url placeholderImage[state.rawValue] = placeholder @@ -47,5 +46,4 @@ public class AsyncButton: UIButton { } } } - } diff --git a/Spring/AsyncImageView.swift b/Spring/AsyncImageView.swift index aa2f7e8..3f0df00 100644 --- a/Spring/AsyncImageView.swift +++ b/Spring/AsyncImageView.swift @@ -24,9 +24,8 @@ import UIKit public class AsyncImageView: UIImageView { - public var placeholderImage : UIImage? - - public var url : NSURL? { + public var placeholderImage: UIImage? + public var url: NSURL? { didSet { self.image = placeholderImage if let urlString = url?.absoluteString { diff --git a/Spring/AutoTextView.swift b/Spring/AutoTextView.swift index 1d0c7e6..189d318 100644 --- a/Spring/AutoTextView.swift +++ b/Spring/AutoTextView.swift @@ -9,7 +9,8 @@ import UIKit public class AutoTextView: UITextView { - + + private let edgeInset: CGFloat = 4 public override var intrinsicContentSize: CGSize { get { var size = self.sizeThatFits(CGSize(width: self.frame.size.width, height: CGFloat.greatestFiniteMagnitude)) @@ -18,7 +19,7 @@ public class AutoTextView: UITextView { size.height = 0 } - contentInset = UIEdgeInsets(top: -4, left: -4, bottom: -4, right: -4) + contentInset = UIEdgeInsets(top: -edgeInset, left: -edgeInset, bottom: -edgeInset, right: -edgeInset) layoutIfNeeded() return size diff --git a/Spring/BlurView.swift b/Spring/BlurView.swift index 8de1611..e8f0d98 100644 --- a/Spring/BlurView.swift +++ b/Spring/BlurView.swift @@ -23,7 +23,7 @@ import UIKit public func insertBlurView (view: UIView, style: UIBlurEffect.Style) -> UIVisualEffectView { - view.backgroundColor = UIColor.clear + view.backgroundColor = .clear let blurEffect = UIBlurEffect(style: style) let blurEffectView = UIVisualEffectView(effect: blurEffect) diff --git a/Spring/DesignableButton.swift b/Spring/DesignableButton.swift index 0612083..e66b562 100644 --- a/Spring/DesignableButton.swift +++ b/Spring/DesignableButton.swift @@ -23,8 +23,8 @@ import UIKit @IBDesignable public class DesignableButton: SpringButton { - - @IBInspectable public var borderColor: UIColor = UIColor.clear { + + @IBInspectable public var borderColor: 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 = .clear { didSet { layer.shadowColor = shadowColor.cgColor } @@ -65,5 +65,5 @@ import UIKit layer.shadowOffset.height = shadowOffsetY } } - + } diff --git a/Spring/DesignableImageView.swift b/Spring/DesignableImageView.swift index 32a90a2..0ce509f 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 = .clear { didSet { layer.borderColor = borderColor.cgColor } @@ -41,5 +41,5 @@ import UIKit layer.cornerRadius = cornerRadius } } - + } diff --git a/Spring/DesignableLabel.swift b/Spring/DesignableLabel.swift index 8d6994b..b2026a9 100644 --- a/Spring/DesignableLabel.swift +++ b/Spring/DesignableLabel.swift @@ -23,7 +23,7 @@ import UIKit @IBDesignable public class DesignableLabel: SpringLabel { - + @IBInspectable public var lineHeight: CGFloat = 1.5 { didSet { let font = UIFont(name: self.font.fontName, size: self.font.pointSize) @@ -39,5 +39,5 @@ import UIKit self.attributedText = attributedString } } - + } diff --git a/Spring/DesignableTabBarController.swift b/Spring/DesignableTabBarController.swift index 6c81095..1d5cfdb 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 = .clear { didSet { UITabBar.appearance().tintColor = normalTint UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: normalTint], for: UIControl.State()) } } - @IBInspectable var selectedTint: UIColor = UIColor.clear { + @IBInspectable var selectedTint: UIColor = .clear { didSet { UITabBar.appearance().tintColor = selectedTint UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: selectedTint], for:UIControl.State.selected) @@ -47,8 +47,8 @@ import UIKit @IBInspectable var firstSelectedImage: UIImage? { didSet { if let image = firstSelectedImage { - var tabBarItems = self.tabBar.items as [UITabBarItem]? - tabBarItems?[0].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) + let tabBarItems = self.tabBar.items as [UITabBarItem]? + tabBarItems?.first?.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]? + let 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]? + let 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]? + let 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]? + let tabBarItems = self.tabBar.items as [UITabBarItem]? tabBarItems?[4].selectedImage = image.withRenderingMode(UIImage.RenderingMode.alwaysTemplate) } } diff --git a/Spring/DesignableTextField.swift b/Spring/DesignableTextField.swift index e334a8e..4b57e01 100644 --- a/Spring/DesignableTextField.swift +++ b/Spring/DesignableTextField.swift @@ -24,7 +24,7 @@ import UIKit @IBDesignable public class DesignableTextField: SpringTextField { - @IBInspectable public var placeholderColor: UIColor = UIColor.clear { + @IBInspectable public var placeholderColor: UIColor = .clear { didSet { guard let placeholder = placeholder else { return } attributedPlaceholder = NSAttributedString(string: placeholder, attributes: [NSAttributedString.Key.foregroundColor: placeholderColor]) @@ -63,7 +63,7 @@ import UIKit } } - @IBInspectable public var borderColor: UIColor = UIColor.clear { + @IBInspectable public var borderColor: UIColor = .clear { didSet { layer.borderColor = borderColor.cgColor } @@ -80,7 +80,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) diff --git a/Spring/DesignableTextView.swift b/Spring/DesignableTextView.swift index 779298a..ebaba50 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 = .clear { didSet { layer.borderColor = borderColor.cgColor } diff --git a/Spring/DesignableView.swift b/Spring/DesignableView.swift index a82d23f..a806bdd 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 = .clear { didSet { layer.borderColor = borderColor.cgColor } @@ -42,7 +42,7 @@ import UIKit } } - @IBInspectable public var shadowColor: UIColor = UIColor.clear { + @IBInspectable public var shadowColor: UIColor = .clear { didSet { layer.shadowColor = shadowColor.cgColor } diff --git a/Spring/ImageLoader.swift b/Spring/ImageLoader.swift index bcb626d..9854eb0 100755 --- a/Spring/ImageLoader.swift +++ b/Spring/ImageLoader.swift @@ -21,16 +21,14 @@ // SOFTWARE. import UIKit -import Foundation - public class ImageLoader { var cache = NSCache() - public class var sharedLoader : ImageLoader { + public class var sharedLoader: ImageLoader { struct Static { - static let instance : ImageLoader = ImageLoader() + static let instance: ImageLoader = ImageLoader() } return Static.instance } diff --git a/Spring/KeyboardLayoutConstraint.swift b/Spring/KeyboardLayoutConstraint.swift index 1b45a56..6fc5379 100644 --- a/Spring/KeyboardLayoutConstraint.swift +++ b/Spring/KeyboardLayoutConstraint.swift @@ -26,8 +26,8 @@ import UIKit @available(tvOS, unavailable) public class KeyboardLayoutConstraint: NSLayoutConstraint { - private var offset : CGFloat = 0 - private var keyboardVisibleHeight : CGFloat = 0 + private var offset: CGFloat = 0 + private var keyboardVisibleHeight: CGFloat = 0 @available(tvOS, unavailable) override public func awakeFromNib() { @@ -66,14 +66,12 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { UIApplication.shared.keyWindow?.layoutIfNeeded() return }, completion: { finished in - }) + }) default: break } - } - } @objc func keyboardWillHideNotification(_ notification: NSNotification) { @@ -95,7 +93,7 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { UIApplication.shared.keyWindow?.layoutIfNeeded() return }, completion: { finished in - }) + }) default: break } @@ -107,4 +105,5 @@ public class KeyboardLayoutConstraint: NSLayoutConstraint { } } + #endif diff --git a/Spring/LoadingView.swift b/Spring/LoadingView.swift index 5f62ce8..e8b474c 100644 --- a/Spring/LoadingView.swift +++ b/Spring/LoadingView.swift @@ -25,9 +25,9 @@ import UIKit #if !os(tvOS) @available(tvOS, unavailable) public class LoadingView: UIView { - + @IBOutlet public weak var indicatorView: SpringView! - + override public func awakeFromNib() { let animation = CABasicAnimation() animation.keyPath = "transform.rotation.z" @@ -37,42 +37,41 @@ public class LoadingView: UIView { animation.repeatCount = HUGE indicatorView.layer.add(animation, forKey: "") } - + 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)!.first as! UIView } } public extension UIView { - + struct LoadingViewConstants { static let Tag = 1000 } - - public func showLoading() { - + + func showLoading() { + if self.viewWithTag(LoadingViewConstants.Tag) != nil { // If loading view is already found in current view hierachy, do nothing return } - + let loadingXibView = LoadingView.designCodeLoadingView() loadingXibView.frame = self.bounds loadingXibView.tag = LoadingViewConstants.Tag self.addSubview(loadingXibView) - + loadingXibView.alpha = 0 SpringAnimation.spring(duration: 0.7, animations: { loadingXibView.alpha = 1 }) } - - public func hideLoading() { - + + func hideLoading() { + if let loadingXibView = self.viewWithTag(LoadingViewConstants.Tag) { loadingXibView.alpha = 1 - + SpringAnimation.springWithCompletion(duration: 0.7, animations: { loadingXibView.alpha = 0 loadingXibView.transform = CGAffineTransform(scaleX: 3, y: 3) @@ -81,6 +80,6 @@ public extension UIView { }) } } - } + #endif diff --git a/Spring/LoadingView.xib b/Spring/LoadingView.xib index 58a95a6..c04a224 100644 --- a/Spring/LoadingView.xib +++ b/Spring/LoadingView.xib @@ -1,17 +1,20 @@ - - + + + - + + + - + - + @@ -21,7 +24,7 @@ - + @@ -30,7 +33,7 @@ - + @@ -38,6 +41,7 @@ + diff --git a/Spring/Misc.swift b/Spring/Misc.swift index 96024b8..3637b0f 100644 --- a/Spring/Misc.swift +++ b/Spring/Misc.swift @@ -59,11 +59,11 @@ public func imageFromURL(_ Url: String) -> UIImage { public extension UIColor { convenience init(hex: String) { - var red: CGFloat = 0.0 - var green: CGFloat = 0.0 - var blue: CGFloat = 0.0 - var alpha: CGFloat = 1.0 - var hex: String = hex + var red: CGFloat = 0.0 + var green: CGFloat = 0.0 + var blue: CGFloat = 0.0 + var alpha: CGFloat = 1.0 + var hex: String = hex if hex.hasPrefix("#") { let index = hex.index(hex.startIndex, offsetBy: 1) @@ -98,7 +98,7 @@ public extension UIColor { } else { print("Scan hex error") } - self.init(red:red, green:green, blue:blue, alpha:alpha) + self.init(red: red, green: green, blue: blue, alpha: alpha) } } @@ -132,11 +132,11 @@ public func dateFromString(date: String, format: String) -> Date { } } -public func randomStringWithLength (len : Int) -> NSString { +public func randomStringWithLength(len: Int) -> NSString { - let letters : NSString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + let letters: NSString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" - let randomString : NSMutableString = NSMutableString(capacity: len) + let randomString = NSMutableString(capacity: len) for _ in 0 ..< len { let length = UInt32 (letters.length) @@ -164,7 +164,7 @@ public func timeAgoSinceDate(date: Date, numericDates: Bool) -> String { latest = now } - let components: DateComponents = calendar.dateComponents(unitFlags, from: earliest, to: latest) + let components = calendar.dateComponents(unitFlags, from: earliest, to: latest) guard let year = components.year, @@ -174,7 +174,7 @@ public func timeAgoSinceDate(date: Date, numericDates: Bool) -> String { let hour = components.hour, let minute = components.minute, let second = components.second - else { + else { fatalError() } @@ -243,16 +243,17 @@ extension UIImageView { let mimeType = response?.mimeType, mimeType.hasPrefix("image"), let data = data, error == nil, let image = UIImage(data: data) - else { - self.image = placeholderImage - return + else { + self.image = placeholderImage + return } DispatchQueue.main.async() { () -> Void in self.image = image } - }.resume() + }.resume() } + func setImage(urlString: String, contentMode mode: UIView.ContentMode = .scaleAspectFit, placeholderImage: UIImage?) { guard let url = URL(string: urlString) else { image = placeholderImage diff --git a/Spring/SoundPlayer.swift b/Spring/SoundPlayer.swift index d2451d9..4545787 100644 --- a/Spring/SoundPlayer.swift +++ b/Spring/SoundPlayer.swift @@ -25,11 +25,11 @@ import AudioToolbox public struct SoundPlayer { - static var filename : String? - static var enabled : Bool = true + static var filename: String? + static var enabled = true private struct Internal { - static var cache = [URL:SystemSoundID]() + static var cache = [URL: SystemSoundID]() } public static func playSound(soundFile: String) { @@ -40,7 +40,7 @@ public struct SoundPlayer { if let url = Bundle.main.url(forResource: soundFile, withExtension: nil) { - var soundID : SystemSoundID = Internal.cache[url] ?? 0 + var soundID: SystemSoundID = Internal.cache[url] ?? 0 if soundID == 0 { AudioServicesCreateSystemSoundID(url as CFURL, &soundID) diff --git a/Spring/Spring.swift b/Spring/Spring.swift index cf86e1a..e7c6fdb 100644 --- a/Spring/Spring.swift +++ b/Spring/Spring.swift @@ -23,23 +23,24 @@ import UIKit @objc public protocol Springable { - var autostart: Bool { get set } - var autohide: Bool { get set } - var animation: String { get set } - var force: CGFloat { get set } - var delay: CGFloat { get set } - var duration: CGFloat { get set } - var damping: CGFloat { get set } - var velocity: CGFloat { get set } - var repeatCount: Float { get set } - var x: CGFloat { get set } - var y: CGFloat { get set } - var scaleX: CGFloat { get set } - var scaleY: CGFloat { get set } - var rotate: CGFloat { get set } - var opacity: CGFloat { get set } - var animateFrom: Bool { get set } - var curve: String { get set } + + var autostart: Bool { get set } + var autohide: Bool { get set } + var animation: String { get set } + var force: CGFloat { get set } + var delay: CGFloat { get set } + var duration: CGFloat { get set } + var damping: CGFloat { get set } + var velocity: CGFloat { get set } + var repeatCount: Float { get set } + var x: CGFloat { get set } + var y: CGFloat { get set } + var scaleX: CGFloat { get set } + var scaleY: CGFloat { get set } + var rotate: CGFloat { get set } + var opacity: CGFloat { get set } + var animateFrom: Bool { get set } + var curve: String { get set } // UIView var layer : CALayer { get } @@ -52,9 +53,9 @@ import UIKit func animateToNext(completion: @escaping () -> ()) } -public class Spring : NSObject { +public class Spring: NSObject { - private unowned var view : Springable + private unowned var view: Springable private var shouldAnimateAfterActive = false private var shouldAnimateInLayoutSubviews = true @@ -79,289 +80,315 @@ public class Spring : NSObject { deinit { NotificationCenter.default.removeObserver(self, name: UIApplication.didBecomeActiveNotification, 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 }} - private var force: CGFloat { set { self.view.force = newValue } get { return self.view.force }} - private var delay: CGFloat { set { self.view.delay = newValue } get { return self.view.delay }} - private var duration: CGFloat { set { self.view.duration = newValue } get { return self.view.duration }} - private var damping: CGFloat { set { self.view.damping = newValue } get { return self.view.damping }} - private var velocity: CGFloat { set { self.view.velocity = newValue } get { return self.view.velocity }} - private var repeatCount: Float { set { self.view.repeatCount = newValue } get { return self.view.repeatCount }} - private var x: CGFloat { set { self.view.x = newValue } get { return self.view.x }} - private var y: CGFloat { set { self.view.y = newValue } get { return self.view.y }} - private var scaleX: CGFloat { set { self.view.scaleX = newValue } get { return self.view.scaleX }} - private var scaleY: CGFloat { set { self.view.scaleY = newValue } get { return self.view.scaleY }} - private var rotate: CGFloat { set { self.view.rotate = newValue } get { return self.view.rotate }} - 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 }} + + 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 }} + private var force: CGFloat { set { self.view.force = newValue } get { return self.view.force }} + private var delay: CGFloat { set { self.view.delay = newValue } get { return self.view.delay }} + private var duration: CGFloat { set { self.view.duration = newValue } get { return self.view.duration }} + private var damping: CGFloat { set { self.view.damping = newValue } get { return self.view.damping }} + private var velocity: CGFloat { set { self.view.velocity = newValue } get { return self.view.velocity }} + private var repeatCount: Float { set { self.view.repeatCount = newValue } get { return self.view.repeatCount }} + private var x: CGFloat { set { self.view.x = newValue } get { return self.view.x }} + private var y: CGFloat { set { self.view.y = newValue } get { return self.view.y }} + private var scaleX: CGFloat { set { self.view.scaleX = newValue } get { return self.view.scaleX }} + private var scaleY: CGFloat { set { self.view.scaleY = newValue } get { return self.view.scaleY }} + private var rotate: CGFloat { set { self.view.rotate = newValue } get { return self.view.rotate }} + 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" - case SlideDown = "slideDown" - case SlideUp = "slideUp" - case SqueezeLeft = "squeezeLeft" - case SqueezeRight = "squeezeRight" - case SqueezeDown = "squeezeDown" - case SqueezeUp = "squeezeUp" - case FadeIn = "fadeIn" - case FadeOut = "fadeOut" - case FadeOutIn = "fadeOutIn" - case FadeInLeft = "fadeInLeft" - case FadeInRight = "fadeInRight" - case FadeInDown = "fadeInDown" - case FadeInUp = "fadeInUp" - case ZoomIn = "zoomIn" - case ZoomOut = "zoomOut" - case Fall = "fall" - case Shake = "shake" - case Pop = "pop" - case FlipX = "flipX" - case FlipY = "flipY" - case Morph = "morph" - case Squeeze = "squeeze" - case Flash = "flash" - case Wobble = "wobble" - case Swing = "swing" + public enum AnimationPreset: String, CaseIterable { + case slideLeft = "slideLeft" + case slideRight = "slideRight" + case slideDown = "slideDown" + case slideUp = "slideUp" + case squeezeLeft = "squeezeLeft" + case squeezeRight = "squeezeRight" + case squeezeDown = "squeezeDown" + case squeezeUp = "squeezeUp" + case fadeIn = "fadeIn" + case fadeOut = "fadeOut" + case fadeOutIn = "fadeOutIn" + case fadeInLeft = "fadeInLeft" + case fadeInRight = "fadeInRight" + case fadeInDown = "fadeInDown" + case fadeInUp = "fadeInUp" + case zoomIn = "zoomIn" + case zoomOut = "zoomOut" + case fall = "fall" + case shake = "shake" + case pop = "pop" + case flipX = "flipX" + case flipY = "flipY" + case morph = "morph" + case squeeze = "squeeze" + case flash = "flash" + case wobble = "wobble" + case swing = "swing" } - public enum AnimationCurve: String { - case EaseIn = "easeIn" - case EaseOut = "easeOut" - case EaseInOut = "easeInOut" - case Linear = "linear" - case Spring = "spring" - case EaseInSine = "easeInSine" - case EaseOutSine = "easeOutSine" - case EaseInOutSine = "easeInOutSine" - case EaseInQuad = "easeInQuad" - case EaseOutQuad = "easeOutQuad" - case EaseInOutQuad = "easeInOutQuad" - case EaseInCubic = "easeInCubic" - case EaseOutCubic = "easeOutCubic" - case EaseInOutCubic = "easeInOutCubic" - case EaseInQuart = "easeInQuart" - case EaseOutQuart = "easeOutQuart" - case EaseInOutQuart = "easeInOutQuart" - case EaseInQuint = "easeInQuint" - case EaseOutQuint = "easeOutQuint" - case EaseInOutQuint = "easeInOutQuint" - case EaseInExpo = "easeInExpo" - case EaseOutExpo = "easeOutExpo" - case EaseInOutExpo = "easeInOutExpo" - case EaseInCirc = "easeInCirc" - case EaseOutCirc = "easeOutCirc" - case EaseInOutCirc = "easeInOutCirc" - case EaseInBack = "easeInBack" - case EaseOutBack = "easeOutBack" - case EaseInOutBack = "easeInOutBack" + public enum AnimationCurve: String, CaseIterable { + case easeIn = "easeIn" + case easeOut = "easeOut" + case easeInOut = "easeInOut" + case linear = "linear" + case spring = "spring" + case easeInSine = "easeInSine" + case easeOutSine = "easeOutSine" + case easeInOutSine = "easeInOutSine" + case easeInQuad = "easeInQuad" + case easeOutQuad = "easeOutQuad" + case easeInOutQuad = "easeInOutQuad" + case easeInCubic = "easeInCubic" + case easeOutCubic = "easeOutCubic" + case easeInOutCubic = "easeInOutCubic" + case easeInQuart = "easeInQuart" + case easeOutQuart = "easeOutQuart" + case easeInOutQuart = "easeInOutQuart" + case easeInQuint = "easeInQuint" + case easeOutQuint = "easeOutQuint" + case easeInOutQuint = "easeInOutQuint" + case easeInExpo = "easeInExpo" + case easeOutExpo = "easeOutExpo" + case easeInOutExpo = "easeInOutExpo" + case easeInCirc = "easeInCirc" + case easeOutCirc = "easeOutCirc" + case easeInOutCirc = "easeInOutCirc" + case easeInBack = "easeInBack" + case easeOutBack = "easeOutBack" + case easeInOutBack = "easeInOutBack" } func animatePreset() { alpha = 0.99 if let animation = AnimationPreset(rawValue: animation) { switch animation { - case .SlideLeft: - x = 300*force - case .SlideRight: - x = -300*force - case .SlideDown: - y = -300*force - case .SlideUp: - y = 300*force - case .SqueezeLeft: - x = 300 - scaleX = 3*force - case .SqueezeRight: - x = -300 - scaleX = 3*force - case .SqueezeDown: - y = -300 - scaleY = 3*force - case .SqueezeUp: - y = 300 - scaleY = 3*force - case .FadeIn: + case .slideLeft: + x = 300 * force + + case .slideRight: + x = -300 * force + + case .slideDown: + y = -300 * force + + case .slideUp: + y = 300 * force + + case .squeezeLeft: + x = 300 + scaleX = 3 * force + + case .squeezeRight: + x = -300 + scaleX = 3 * force + + case .squeezeDown: + y = -300 + scaleY = 3 * force + + case .squeezeUp: + y = 300 + scaleY = 3 * force + + case .fadeIn: opacity = 0 - case .FadeOut: + + case .fadeOut: animateFrom = false - opacity = 0 - case .FadeOutIn: - let animation = CABasicAnimation() - animation.keyPath = "opacity" - animation.fromValue = 1 - animation.toValue = 0 + opacity = 0 + + case .fadeOutIn: + let animation = CABasicAnimation() + animation.keyPath = "opacity" + animation.fromValue = 1 + animation.toValue = 0 animation.timingFunction = getTimingFunction(curve: curve) - animation.duration = CFTimeInterval(duration) - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) - animation.autoreverses = true + animation.duration = CFTimeInterval(duration) + animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + animation.autoreverses = true layer.add(animation, forKey: "fade") - case .FadeInLeft: + + case .fadeInLeft: opacity = 0 - x = 300*force - case .FadeInRight: - x = -300*force + x = 300 * force + + case .fadeInRight: + x = -300 * force opacity = 0 - case .FadeInDown: - y = -300*force + + case .fadeInDown: + y = -300 * force opacity = 0 - case .FadeInUp: - y = 300*force + + case .fadeInUp: + y = 300 * force opacity = 0 - case .ZoomIn: + + case .zoomIn: opacity = 0 - scaleX = 2*force - scaleY = 2*force - case .ZoomOut: + scaleX = 2 * force + scaleY = 2 * force + + case .zoomOut: animateFrom = false opacity = 0 - scaleX = 2*force - scaleY = 2*force - case .Fall: + scaleX = 2 * force + scaleY = 2 * force + + case .fall: animateFrom = false - rotate = 15 * CGFloat(CGFloat.pi/180) - y = 600*force - case .Shake: - let animation = CAKeyframeAnimation() - 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] + rotate = 15 * CGFloat(CGFloat.pi/180) + y = 600 * force + + case .shake: + let animation = CAKeyframeAnimation() + 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: curve) - animation.duration = CFTimeInterval(duration) - animation.isAdditive = true - animation.repeatCount = repeatCount - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + animation.duration = CFTimeInterval(duration) + animation.isAdditive = true + animation.repeatCount = repeatCount + animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) 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] + + 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: curve) - animation.duration = CFTimeInterval(duration) - animation.isAdditive = true - animation.repeatCount = repeatCount - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + animation.duration = CFTimeInterval(duration) + animation.isAdditive = true + animation.repeatCount = repeatCount + animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(animation, forKey: "pop") - case .FlipX: - rotate = 0 - scaleX = 1 - scaleY = 1 + + case .flipX: + rotate = 0 + scaleX = 1 + 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: - CATransform3DConcat(perspective, CATransform3DMakeRotation(CGFloat(CGFloat.pi), 0, 1, 0))) - animation.duration = CFTimeInterval(duration) - animation.repeatCount = repeatCount - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + let animation = CABasicAnimation() + animation.keyPath = "transform" + animation.fromValue = NSValue(caTransform3D: CATransform3DMakeRotation(0, 0, 0, 0)) + 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") - case .FlipY: - 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: - CATransform3DConcat(perspective,CATransform3DMakeRotation(CGFloat(CGFloat.pi), 1, 0, 0))) - animation.duration = CFTimeInterval(duration) - animation.repeatCount = repeatCount - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + case .flipY: + 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: + 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") - 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] + + 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: curve) - morphX.duration = CFTimeInterval(duration) - morphX.repeatCount = repeatCount - morphX.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + morphX.duration = CFTimeInterval(duration) + 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] - morphY.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] + 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: curve) - morphY.duration = CFTimeInterval(duration) - morphY.repeatCount = repeatCount - morphY.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + morphY.duration = CFTimeInterval(duration) + morphY.repeatCount = repeatCount + morphY.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) 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] + + 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: curve) - morphX.duration = CFTimeInterval(duration) - morphX.repeatCount = repeatCount - morphX.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + morphX.duration = CFTimeInterval(duration) + 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] - morphY.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] + 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: curve) - morphY.duration = CFTimeInterval(duration) - morphY.repeatCount = repeatCount - morphY.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + morphY.duration = CFTimeInterval(duration) + morphY.repeatCount = repeatCount + morphY.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(morphY, forKey: "morphY") - case .Flash: - let animation = CABasicAnimation() - animation.keyPath = "opacity" - animation.fromValue = 1 - animation.toValue = 0 - animation.duration = CFTimeInterval(duration) - animation.repeatCount = repeatCount * 2.0 + + case .flash: + let animation = CABasicAnimation() + animation.keyPath = "opacity" + animation.fromValue = 1 + animation.toValue = 0 + animation.duration = CFTimeInterval(duration) + animation.repeatCount = repeatCount * 2.0 animation.autoreverses = true - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) 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) + + 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.isAdditive = true - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + 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] - x.keyTimes = [0, 0.2, 0.4, 0.6, 0.8, 1] + 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: curve) - x.duration = CFTimeInterval(duration) - x.isAdditive = true - x.repeatCount = repeatCount - x.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + x.duration = CFTimeInterval(duration) + x.isAdditive = true + x.repeatCount = repeatCount + x.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) 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.isAdditive = true + + 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.isAdditive = true animation.repeatCount = repeatCount - animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) + animation.beginTime = CACurrentMediaTime() + CFTimeInterval(delay) layer.add(animation, forKey: "swing") } } @@ -370,35 +397,35 @@ public class Spring : NSObject { func getTimingFunction(curve: String) -> CAMediaTimingFunction { if let curve = AnimationCurve(rawValue: curve) { switch curve { - 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) - case .EaseInOutSine: return CAMediaTimingFunction(controlPoints: 0.445, 0.05, 0.55, 0.95) - case .EaseInQuad: return CAMediaTimingFunction(controlPoints: 0.55, 0.085, 0.68, 0.53) - case .EaseOutQuad: return CAMediaTimingFunction(controlPoints: 0.25, 0.46, 0.45, 0.94) - case .EaseInOutQuad: return CAMediaTimingFunction(controlPoints: 0.455, 0.03, 0.515, 0.955) - case .EaseInCubic: return CAMediaTimingFunction(controlPoints: 0.55, 0.055, 0.675, 0.19) - case .EaseOutCubic: return CAMediaTimingFunction(controlPoints: 0.215, 0.61, 0.355, 1) - case .EaseInOutCubic: return CAMediaTimingFunction(controlPoints: 0.645, 0.045, 0.355, 1) - case .EaseInQuart: return CAMediaTimingFunction(controlPoints: 0.895, 0.03, 0.685, 0.22) - case .EaseOutQuart: return CAMediaTimingFunction(controlPoints: 0.165, 0.84, 0.44, 1) - case .EaseInOutQuart: return CAMediaTimingFunction(controlPoints: 0.77, 0, 0.175, 1) - case .EaseInQuint: return CAMediaTimingFunction(controlPoints: 0.755, 0.05, 0.855, 0.06) - case .EaseOutQuint: return CAMediaTimingFunction(controlPoints: 0.23, 1, 0.32, 1) - case .EaseInOutQuint: return CAMediaTimingFunction(controlPoints: 0.86, 0, 0.07, 1) - case .EaseInExpo: return CAMediaTimingFunction(controlPoints: 0.95, 0.05, 0.795, 0.035) - case .EaseOutExpo: return CAMediaTimingFunction(controlPoints: 0.19, 1, 0.22, 1) - case .EaseInOutExpo: return CAMediaTimingFunction(controlPoints: 1, 0, 0, 1) - case .EaseInCirc: return CAMediaTimingFunction(controlPoints: 0.6, 0.04, 0.98, 0.335) - case .EaseOutCirc: return CAMediaTimingFunction(controlPoints: 0.075, 0.82, 0.165, 1) - case .EaseInOutCirc: return CAMediaTimingFunction(controlPoints: 0.785, 0.135, 0.15, 0.86) - case .EaseInBack: return CAMediaTimingFunction(controlPoints: 0.6, -0.28, 0.735, 0.045) - case .EaseOutBack: return CAMediaTimingFunction(controlPoints: 0.175, 0.885, 0.32, 1.275) - case .EaseInOutBack: return CAMediaTimingFunction(controlPoints: 0.68, -0.55, 0.265, 1.55) + 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) + case .easeInOutSine: return CAMediaTimingFunction(controlPoints: 0.445, 0.05, 0.55, 0.95) + case .easeInQuad: return CAMediaTimingFunction(controlPoints: 0.55, 0.085, 0.68, 0.53) + case .easeOutQuad: return CAMediaTimingFunction(controlPoints: 0.25, 0.46, 0.45, 0.94) + case .easeInOutQuad: return CAMediaTimingFunction(controlPoints: 0.455, 0.03, 0.515, 0.955) + case .easeInCubic: return CAMediaTimingFunction(controlPoints: 0.55, 0.055, 0.675, 0.19) + case .easeOutCubic: return CAMediaTimingFunction(controlPoints: 0.215, 0.61, 0.355, 1) + case .easeInOutCubic: return CAMediaTimingFunction(controlPoints: 0.645, 0.045, 0.355, 1) + case .easeInQuart: return CAMediaTimingFunction(controlPoints: 0.895, 0.03, 0.685, 0.22) + case .easeOutQuart: return CAMediaTimingFunction(controlPoints: 0.165, 0.84, 0.44, 1) + case .easeInOutQuart: return CAMediaTimingFunction(controlPoints: 0.77, 0, 0.175, 1) + case .easeInQuint: return CAMediaTimingFunction(controlPoints: 0.755, 0.05, 0.855, 0.06) + case .easeOutQuint: return CAMediaTimingFunction(controlPoints: 0.23, 1, 0.32, 1) + case .easeInOutQuint: return CAMediaTimingFunction(controlPoints: 0.86, 0, 0.07, 1) + case .easeInExpo: return CAMediaTimingFunction(controlPoints: 0.95, 0.05, 0.795, 0.035) + case .easeOutExpo: return CAMediaTimingFunction(controlPoints: 0.19, 1, 0.22, 1) + case .easeInOutExpo: return CAMediaTimingFunction(controlPoints: 1, 0, 0, 1) + case .easeInCirc: return CAMediaTimingFunction(controlPoints: 0.6, 0.04, 0.98, 0.335) + case .easeOutCirc: return CAMediaTimingFunction(controlPoints: 0.075, 0.82, 0.165, 1) + case .easeInOutCirc: return CAMediaTimingFunction(controlPoints: 0.785, 0.135, 0.15, 0.86) + case .easeInBack: return CAMediaTimingFunction(controlPoints: 0.6, -0.28, 0.735, 0.045) + case .easeOutBack: return CAMediaTimingFunction(controlPoints: 0.175, 0.885, 0.32, 1.275) + case .easeInOutBack: return CAMediaTimingFunction(controlPoints: 0.68, -0.55, 0.265, 1.55) } } return CAMediaTimingFunction(name: CAMediaTimingFunctionName.default) @@ -407,9 +434,9 @@ public class Spring : NSObject { func getAnimationOptions(curve: String) -> UIView.AnimationOptions { if let curve = AnimationCurve(rawValue: curve) { switch curve { - case .EaseIn: return UIView.AnimationOptions.curveEaseIn - case .EaseOut: return UIView.AnimationOptions.curveEaseOut - case .EaseInOut: return UIView.AnimationOptions() + case .easeIn: return UIView.AnimationOptions.curveEaseIn + case .easeOut: return UIView.AnimationOptions.curveEaseOut + case .easeInOut: return UIView.AnimationOptions() default: break } } @@ -466,11 +493,11 @@ public class Spring : NSObject { func setView(completion: @escaping () -> ()) { if animateFrom { - 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 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.concatenating(scale) - self.transform = rotate.concatenating(translateAndScale) + self.transform = rotate.concatenating(translateAndScale) self.alpha = self.opacity } @@ -488,23 +515,23 @@ public class Spring : NSObject { _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 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.concatenating(scale) - _self.transform = rotate.concatenating(translateAndScale) + _self.transform = rotate.concatenating(translateAndScale) _self.alpha = _self.opacity } } - }, completion: { [weak self] finished in - - completion() - self?.resetAll() - - }) + }, completion: { [weak self] finished in + + completion() + self?.resetAll() + + }) } @@ -517,16 +544,16 @@ public class Spring : NSObject { func resetAll() { x = 0 y = 0 - animation = "" - opacity = 1 - scaleX = 1 - scaleY = 1 - rotate = 0 - damping = 0.7 - velocity = 0.7 + animation = "" + opacity = 1 + scaleX = 1 + scaleY = 1 + rotate = 0 + damping = 0.7 + velocity = 0.7 repeatCount = 1 - delay = 0 - duration = 0.7 + delay = 0 + duration = 0.7 } } diff --git a/Spring/SpringAnimation.swift b/Spring/SpringAnimation.swift index 998882b..b8b78c8 100644 --- a/Spring/SpringAnimation.swift +++ b/Spring/SpringAnimation.swift @@ -36,7 +36,7 @@ import UIKit completion: nil ) } - + public class func springEaseIn(duration: TimeInterval, animations: (() -> Void)!) { UIView.animate( withDuration: duration, @@ -48,7 +48,7 @@ import UIKit completion: nil ) } - + public class func springEaseOut(duration: TimeInterval, animations: (() -> Void)!) { UIView.animate( withDuration: duration, @@ -59,7 +59,7 @@ import UIKit }, completion: nil ) } - + public class func springEaseInOut(duration: TimeInterval, animations: (() -> Void)!) { UIView.animate( withDuration: duration, @@ -70,7 +70,7 @@ import UIKit }, completion: nil ) } - + public class func springLinear(duration: TimeInterval, animations: (() -> Void)!) { UIView.animate( withDuration: duration, @@ -81,7 +81,7 @@ import UIKit }, completion: nil ) } - + public class func springWithDelay(duration: TimeInterval, delay: TimeInterval, animations: (() -> Void)!) { UIView.animate( withDuration: duration, @@ -94,7 +94,7 @@ import UIKit }, completion: nil ) } - + public class func springWithCompletion(duration: TimeInterval, animations: (() -> Void)!, completion: ((Bool) -> Void)!) { UIView.animate( withDuration: duration, diff --git a/Spring/SpringButton.swift b/Spring/SpringButton.swift index 92124ea..80a96fa 100644 --- a/Spring/SpringButton.swift +++ b/Spring/SpringButton.swift @@ -23,48 +23,49 @@ import UIKit open class SpringButton: UIButton, Springable { - @IBInspectable public var autostart: Bool = false - @IBInspectable public var autohide: Bool = false - @IBInspectable public var animation: String = "" - @IBInspectable public var force: CGFloat = 1 - @IBInspectable public var delay: CGFloat = 0 - @IBInspectable public var duration: CGFloat = 0.7 - @IBInspectable public var damping: CGFloat = 0.7 - @IBInspectable public var velocity: CGFloat = 0.7 + + @IBInspectable public var autostart = false + @IBInspectable public var autohide = false + @IBInspectable public var animation: String = "" + @IBInspectable public var force: CGFloat = 1 + @IBInspectable public var delay: CGFloat = 0 + @IBInspectable public var duration: CGFloat = 0.7 + @IBInspectable public var damping: CGFloat = 0.7 + @IBInspectable public var velocity: CGFloat = 0.7 @IBInspectable public var repeatCount: Float = 1 - @IBInspectable public var x: CGFloat = 0 - @IBInspectable public var y: CGFloat = 0 - @IBInspectable public var scaleX: CGFloat = 1 - @IBInspectable public var scaleY: CGFloat = 1 - @IBInspectable public var rotate: CGFloat = 0 - @IBInspectable public var curve: String = "" - public var opacity: CGFloat = 1 - public var animateFrom: Bool = false - - lazy private var spring : Spring = Spring(self) - + @IBInspectable public var x: CGFloat = 0 + @IBInspectable public var y: CGFloat = 0 + @IBInspectable public var scaleX: CGFloat = 1 + @IBInspectable public var scaleY: CGFloat = 1 + @IBInspectable public var rotate: CGFloat = 0 + @IBInspectable public var curve: String = "" + public var opacity: CGFloat = 1 + public var animateFrom = false + + lazy private var spring: Spring = Spring(self) + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } - + public func animate() { self.spring.animate() } - + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } - + public func animateTo() { self.spring.animateTo() } - + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } diff --git a/Spring/SpringImageView.swift b/Spring/SpringImageView.swift index 85ad61f..7cbef8b 100644 --- a/Spring/SpringImageView.swift +++ b/Spring/SpringImageView.swift @@ -23,50 +23,51 @@ import UIKit open class SpringImageView: UIImageView, Springable { - @IBInspectable public var autostart: Bool = false - @IBInspectable public var autohide: Bool = false - @IBInspectable public var animation: String = "" - @IBInspectable public var force: CGFloat = 1 - @IBInspectable public var delay: CGFloat = 0 - @IBInspectable public var duration: CGFloat = 0.7 - @IBInspectable public var damping: CGFloat = 0.7 - @IBInspectable public var velocity: CGFloat = 0.7 - @IBInspectable public var repeatCount: Float = 1 - @IBInspectable public var x: CGFloat = 0 - @IBInspectable public var y: CGFloat = 0 - @IBInspectable public var scaleX: CGFloat = 1 - @IBInspectable public var scaleY: CGFloat = 1 - @IBInspectable public var rotate: CGFloat = 0 - @IBInspectable public var curve: String = "" - public var opacity: CGFloat = 1 - public var animateFrom: Bool = false - - lazy private var spring : Spring = Spring(self) - + + @IBInspectable public var autostart = false + @IBInspectable public var autohide = false + @IBInspectable public var animation: String = "" + @IBInspectable public var force: CGFloat = 1 + @IBInspectable public var delay: CGFloat = 0 + @IBInspectable public var duration: CGFloat = 0.7 + @IBInspectable public var damping: CGFloat = 0.7 + @IBInspectable public var velocity: CGFloat = 0.7 + @IBInspectable public var repeatCount: Float = 1 + @IBInspectable public var x: CGFloat = 0 + @IBInspectable public var y: CGFloat = 0 + @IBInspectable public var scaleX: CGFloat = 1 + @IBInspectable public var scaleY: CGFloat = 1 + @IBInspectable public var rotate: CGFloat = 0 + @IBInspectable public var curve: String = "" + public var opacity: CGFloat = 1 + public var animateFrom = false + + lazy private var spring: Spring = Spring(self) + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } - + public func animate() { self.spring.animate() } - + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } - + public func animateTo() { self.spring.animateTo() } - + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } - + } diff --git a/Spring/SpringLabel.swift b/Spring/SpringLabel.swift index c105a48..9b0af82 100644 --- a/Spring/SpringLabel.swift +++ b/Spring/SpringLabel.swift @@ -23,50 +23,51 @@ import UIKit open class SpringLabel: UILabel, Springable { - @IBInspectable public var autostart: Bool = false - @IBInspectable public var autohide: Bool = false - @IBInspectable public var animation: String = "" - @IBInspectable public var force: CGFloat = 1 - @IBInspectable public var delay: CGFloat = 0 - @IBInspectable public var duration: CGFloat = 0.7 - @IBInspectable public var damping: CGFloat = 0.7 - @IBInspectable public var velocity: CGFloat = 0.7 - @IBInspectable public var repeatCount: Float = 1 - @IBInspectable public var x: CGFloat = 0 - @IBInspectable public var y: CGFloat = 0 - @IBInspectable public var scaleX: CGFloat = 1 - @IBInspectable public var scaleY: CGFloat = 1 - @IBInspectable public var rotate: CGFloat = 0 - @IBInspectable public var curve: String = "" - public var opacity: CGFloat = 1 - public var animateFrom: Bool = false - - lazy private var spring : Spring = Spring(self) - + + @IBInspectable public var autostart = false + @IBInspectable public var autohide = false + @IBInspectable public var animation: String = "" + @IBInspectable public var force: CGFloat = 1 + @IBInspectable public var delay: CGFloat = 0 + @IBInspectable public var duration: CGFloat = 0.7 + @IBInspectable public var damping: CGFloat = 0.7 + @IBInspectable public var velocity: CGFloat = 0.7 + @IBInspectable public var repeatCount: Float = 1 + @IBInspectable public var x: CGFloat = 0 + @IBInspectable public var y: CGFloat = 0 + @IBInspectable public var scaleX: CGFloat = 1 + @IBInspectable public var scaleY: CGFloat = 1 + @IBInspectable public var rotate: CGFloat = 0 + @IBInspectable public var curve: String = "" + public var opacity: CGFloat = 1 + public var animateFrom = false + + lazy private var spring: Spring = Spring(self) + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } - + public func animate() { self.spring.animate() } - + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } - + public func animateTo() { self.spring.animateTo() } - + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } - + } diff --git a/Spring/SpringTextField.swift b/Spring/SpringTextField.swift index 966b6f7..72c6264 100644 --- a/Spring/SpringTextField.swift +++ b/Spring/SpringTextField.swift @@ -23,48 +23,49 @@ import UIKit open class SpringTextField: UITextField, Springable { - @IBInspectable public var autostart: Bool = false - @IBInspectable public var autohide: Bool = false - @IBInspectable public var animation: String = "" - @IBInspectable public var force: CGFloat = 1 - @IBInspectable public var delay: CGFloat = 0 - @IBInspectable public var duration: CGFloat = 0.7 - @IBInspectable public var damping: CGFloat = 0.7 - @IBInspectable public var velocity: CGFloat = 0.7 - @IBInspectable public var repeatCount: Float = 1 - @IBInspectable public var x: CGFloat = 0 - @IBInspectable public var y: CGFloat = 0 - @IBInspectable public var scaleX: CGFloat = 1 - @IBInspectable public var scaleY: CGFloat = 1 - @IBInspectable public var rotate: CGFloat = 0 - @IBInspectable public var curve: String = "" - public var opacity: CGFloat = 1 - public var animateFrom: Bool = false - - lazy private var spring : Spring = Spring(self) - + + @IBInspectable public var autostart = false + @IBInspectable public var autohide = false + @IBInspectable public var animation: String = "" + @IBInspectable public var force: CGFloat = 1 + @IBInspectable public var delay: CGFloat = 0 + @IBInspectable public var duration: CGFloat = 0.7 + @IBInspectable public var damping: CGFloat = 0.7 + @IBInspectable public var velocity: CGFloat = 0.7 + @IBInspectable public var repeatCount: Float = 1 + @IBInspectable public var x: CGFloat = 0 + @IBInspectable public var y: CGFloat = 0 + @IBInspectable public var scaleX: CGFloat = 1 + @IBInspectable public var scaleY: CGFloat = 1 + @IBInspectable public var rotate: CGFloat = 0 + @IBInspectable public var curve: String = "" + public var opacity: CGFloat = 1 + public var animateFrom = false + + lazy private var spring: Spring = Spring(self) + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } - + public func animate() { self.spring.animate() } - + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } - + public func animateTo() { self.spring.animateTo() } - + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } diff --git a/Spring/SpringTextView.swift b/Spring/SpringTextView.swift index 55d4e4a..23a0868 100644 --- a/Spring/SpringTextView.swift +++ b/Spring/SpringTextView.swift @@ -23,50 +23,51 @@ import UIKit open class SpringTextView: UITextView, Springable { - @IBInspectable public var autostart: Bool = false - @IBInspectable public var autohide: Bool = false - @IBInspectable public var animation: String = "" - @IBInspectable public var force: CGFloat = 1 - @IBInspectable public var delay: CGFloat = 0 - @IBInspectable public var duration: CGFloat = 0.7 - @IBInspectable public var damping: CGFloat = 0.7 - @IBInspectable public var velocity: CGFloat = 0.7 - @IBInspectable public var repeatCount: Float = 1 - @IBInspectable public var x: CGFloat = 0 - @IBInspectable public var y: CGFloat = 0 - @IBInspectable public var scaleX: CGFloat = 1 - @IBInspectable public var scaleY: CGFloat = 1 - @IBInspectable public var rotate: CGFloat = 0 - @IBInspectable public var curve: String = "" - public var opacity: CGFloat = 1 - public var animateFrom: Bool = false - - lazy private var spring : Spring = Spring(self) - + + @IBInspectable public var autostart = false + @IBInspectable public var autohide = false + @IBInspectable public var animation: String = "" + @IBInspectable public var force: CGFloat = 1 + @IBInspectable public var delay: CGFloat = 0 + @IBInspectable public var duration: CGFloat = 0.7 + @IBInspectable public var damping: CGFloat = 0.7 + @IBInspectable public var velocity: CGFloat = 0.7 + @IBInspectable public var repeatCount: Float = 1 + @IBInspectable public var x: CGFloat = 0 + @IBInspectable public var y: CGFloat = 0 + @IBInspectable public var scaleX: CGFloat = 1 + @IBInspectable public var scaleY: CGFloat = 1 + @IBInspectable public var rotate: CGFloat = 0 + @IBInspectable public var curve: String = "" + public var opacity: CGFloat = 1 + public var animateFrom = false + + lazy private var spring: Spring = Spring(self) + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() } - + public func animate() { self.spring.animate() } - + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } - + public func animateTo() { self.spring.animateTo() } - + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } - + } diff --git a/Spring/SpringView.swift b/Spring/SpringView.swift index a00c12a..7a00e32 100644 --- a/Spring/SpringView.swift +++ b/Spring/SpringView.swift @@ -23,31 +23,32 @@ import UIKit open class SpringView: UIView, Springable { - @IBInspectable public var autostart: Bool = false - @IBInspectable public var autohide: Bool = false - @IBInspectable public var animation: String = "" - @IBInspectable public var force: CGFloat = 1 - @IBInspectable public var delay: CGFloat = 0 - @IBInspectable public var duration: CGFloat = 0.7 - @IBInspectable public var damping: CGFloat = 0.7 - @IBInspectable public var velocity: CGFloat = 0.7 - @IBInspectable public var repeatCount: Float = 1 - @IBInspectable public var x: CGFloat = 0 - @IBInspectable public var y: CGFloat = 0 - @IBInspectable public var scaleX: CGFloat = 1 - @IBInspectable public var scaleY: CGFloat = 1 - @IBInspectable public var rotate: CGFloat = 0 - @IBInspectable public var curve: String = "" - public var opacity: CGFloat = 1 - public var animateFrom: Bool = false - - lazy private var spring : Spring = Spring(self) - + + @IBInspectable public var autostart = false + @IBInspectable public var autohide = false + @IBInspectable public var animation: String = "" + @IBInspectable public var force: CGFloat = 1 + @IBInspectable public var delay: CGFloat = 0 + @IBInspectable public var duration: CGFloat = 0.7 + @IBInspectable public var damping: CGFloat = 0.7 + @IBInspectable public var velocity: CGFloat = 0.7 + @IBInspectable public var repeatCount: Float = 1 + @IBInspectable public var x: CGFloat = 0 + @IBInspectable public var y: CGFloat = 0 + @IBInspectable public var scaleX: CGFloat = 1 + @IBInspectable public var scaleY: CGFloat = 1 + @IBInspectable public var rotate: CGFloat = 0 + @IBInspectable public var curve: String = "" + public var opacity: CGFloat = 1 + public var animateFrom = false + + lazy private var spring: Spring = Spring(self) + override open func awakeFromNib() { super.awakeFromNib() self.spring.customAwakeFromNib() } - + open override func layoutSubviews() { super.layoutSubviews() spring.customLayoutSubviews() @@ -56,15 +57,15 @@ open class SpringView: UIView, Springable { public func animate() { self.spring.animate() } - + public func animateNext(completion: @escaping () -> ()) { self.spring.animateNext(completion: completion) } - + public func animateTo() { self.spring.animateTo() } - + public func animateToNext(completion: @escaping () -> ()) { self.spring.animateToNext(completion: completion) } diff --git a/Spring/TransitionManager.swift b/Spring/TransitionManager.swift index 388edac..fd6f51e 100644 --- a/Spring/TransitionManager.swift +++ b/Spring/TransitionManager.swift @@ -28,40 +28,40 @@ public class TransitionManager: NSObject, UIViewControllerTransitioningDelegate, var duration = 0.3 public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { - let container = transitionContext.containerView - let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)! - let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)! + let container = transitionContext.containerView + let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)! + let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)! if isPresenting { - toView.frame = container.bounds - toView.transform = CGAffineTransform(translationX: 0, y: container.frame.size.height) + toView.frame = container.bounds + toView.transform = CGAffineTransform(translationX: 0, y: container.frame.size.height) container.addSubview(fromView) container.addSubview(toView) SpringAnimation.springEaseInOut(duration: duration) { - fromView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) - fromView.alpha = 0.5 - toView.transform = CGAffineTransform.identity + fromView.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) + fromView.alpha = 0.5 + toView.transform = CGAffineTransform.identity } } else { - + // 1. Rotating will change the bounds // 2. we have to properly reset toView // to the actual container's bounds, at // the same time take consideration of // previous transformation when presenting - let transform = toView.transform - toView.transform = CGAffineTransform.identity - toView.frame = container.bounds - toView.transform = transform - + let transform = toView.transform + toView.transform = CGAffineTransform.identity + toView.frame = container.bounds + toView.transform = transform + container.addSubview(toView) container.addSubview(fromView) - + SpringAnimation.springEaseInOut(duration: duration) { - fromView.transform = CGAffineTransform(translationX: 0, y: fromView.frame.size.height) - toView.transform = CGAffineTransform.identity - toView.alpha = 1 + fromView.transform = CGAffineTransform(translationX: 0, y: fromView.frame.size.height) + toView.transform = CGAffineTransform.identity + toView.alpha = 1 } } diff --git a/Spring/TransitionZoom.swift b/Spring/TransitionZoom.swift index 6cf5301..e9d6f15 100644 --- a/Spring/TransitionZoom.swift +++ b/Spring/TransitionZoom.swift @@ -24,39 +24,28 @@ import UIKit public class TransitionZoom: NSObject, UIViewControllerTransitioningDelegate, UIViewControllerAnimatedTransitioning { - var isPresenting = true - var duration = 0.4 + var isPresenting = true + var duration = 0.4 public func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { - let container = transitionContext.containerView - let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)! - let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)! + let container = transitionContext.containerView + let fromView = transitionContext.view(forKey: UITransitionContextViewKey.from)! + let toView = transitionContext.view(forKey: UITransitionContextViewKey.to)! - if isPresenting { container.addSubview(fromView) container.addSubview(toView) - toView.alpha = 0 - toView.transform = CGAffineTransform(scaleX: 2, y: 2) - - SpringAnimation.springEaseInOut(duration: duration) { - fromView.transform = CGAffineTransform(scaleX: 0.5, y: 0.5) - fromView.alpha = 0 - toView.transform = CGAffineTransform.identity - toView.alpha = 1 - } - } - else { - container.addSubview(toView) - container.addSubview(fromView) + toView.alpha = isPresenting ? 0 : 1 + toView.transform = CGAffineTransform(scaleX: self.isPresenting ? 2 : 1, + y: self.isPresenting ? 2 : 1) SpringAnimation.springEaseInOut(duration: duration) { - fromView.transform = CGAffineTransform(scaleX: 2, y: 2) - fromView.alpha = 0 - toView.transform = CGAffineTransform(scaleX: 1, y: 1) - toView.alpha = 1 + fromView.transform = CGAffineTransform(scaleX: self.isPresenting ? 0.5 : 2, + y: self.isPresenting ? 0.5 : 2) + fromView.alpha = 0 + toView.transform = CGAffineTransform.identity + toView.alpha = 1 } - } delay(delay: duration, closure: { transitionContext.completeTransition(true) diff --git a/Spring/UnwindSegue.swift b/Spring/UnwindSegue.swift index 53a71cb..2080094 100644 --- a/Spring/UnwindSegue.swift +++ b/Spring/UnwindSegue.swift @@ -23,5 +23,5 @@ import UIKit public extension UIViewController { - @IBAction public func unwindToViewController (_ segue: UIStoryboardSegue){} + @IBAction func unwindToViewController (_ segue: UIStoryboardSegue){} } diff --git a/SpringApp.xcodeproj/project.pbxproj b/SpringApp.xcodeproj/project.pbxproj index a0e8956..4074b74 100644 --- a/SpringApp.xcodeproj/project.pbxproj +++ b/SpringApp.xcodeproj/project.pbxproj @@ -408,7 +408,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1230; ORGANIZATIONNAME = "Meng To"; TargetAttributes = { 1A4FDA321A6E44780099D309 = { @@ -433,10 +433,9 @@ }; buildConfigurationList = 964117361A5BE90A000E3A5A /* Build configuration list for PBXProject "SpringApp" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -611,7 +610,7 @@ ); INFOPLIST_FILE = Spring/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -634,7 +633,7 @@ DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = Spring/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -655,7 +654,7 @@ "$(inherited)", ); INFOPLIST_FILE = SpringTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -668,7 +667,7 @@ isa = XCBuildConfiguration; buildSettings = { INFOPLIST_FILE = SpringTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.1; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.jamztang.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -682,6 +681,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -690,14 +690,17 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -722,7 +725,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -735,6 +738,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -743,14 +747,17 @@ CLANG_WARN_BOOL_CONVERSION = YES; CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = 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_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -768,7 +775,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_SWIFT3_OBJC_INFERENCE = Off; @@ -781,7 +788,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = SpringApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; @@ -795,7 +802,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = SpringApp/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "designcode.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme index ecfaae8..7b50440 100644 --- a/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme +++ b/SpringApp.xcodeproj/xcshareddata/xcschemes/Spring.xcscheme @@ -1,6 +1,6 @@ - - - - + + + + @@ -77,17 +86,6 @@ - - - - - - - - - + + - + + @@ -21,12 +23,14 @@ - + + + @@ -40,8 +44,8 @@ - - - + + + - - - - + - - - - - - - - - - - - - - - - + - + - - - + - - - - - - - - + + - - - - - - - - - - - - - + - + + + + @@ -146,6 +124,7 @@ + @@ -156,6 +135,7 @@ + @@ -168,16 +148,19 @@ - + @@ -213,7 +196,7 @@ - + @@ -238,7 +221,7 @@ - + @@ -249,10 +232,11 @@ - + - + + + @@ -281,10 +269,10 @@ - + - + @@ -305,7 +293,7 @@ - + @@ -327,10 +315,11 @@ - + - + + @@ -353,11 +344,13 @@ + @@ -370,11 +363,13 @@ + @@ -387,11 +382,13 @@ + @@ -404,11 +401,13 @@ + @@ -421,11 +420,13 @@ + @@ -438,14 +439,16 @@ -