diff --git a/Example/Cartfile.resolved b/Example/Cartfile.resolved index 06a76c1..2bbbe22 100644 --- a/Example/Cartfile.resolved +++ b/Example/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Quick/Nimble" "v5.0.0" -github "Quick/Quick" "v0.10.0" +github "Quick/Nimble" "v8.0.1" +github "Quick/Quick" "v2.0.0" diff --git a/Example/Example/RazzleDazzleDemo.xcodeproj/project.pbxproj b/Example/Example/RazzleDazzleDemo.xcodeproj/project.pbxproj index 7fdee18..829feba 100644 --- a/Example/Example/RazzleDazzleDemo.xcodeproj/project.pbxproj +++ b/Example/Example/RazzleDazzleDemo.xcodeproj/project.pbxproj @@ -177,7 +177,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = IFTTT; TargetAttributes = { FAD1C7471B2F57D60053D880 = { @@ -194,7 +194,7 @@ }; buildConfigurationList = FAD1C7431B2F57D60053D880 /* Build configuration list for PBXProject "RazzleDazzleDemo" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -283,18 +283,27 @@ 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; 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_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_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; @@ -323,6 +332,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -330,18 +340,27 @@ 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; 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_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_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; @@ -362,6 +381,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; VALIDATE_PRODUCT = YES; }; name = Release; @@ -375,7 +395,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -389,7 +409,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -410,7 +430,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RazzleDazzleDemo.app/RazzleDazzleDemo"; }; name = Debug; @@ -427,7 +447,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/RazzleDazzleDemo.app/RazzleDazzleDemo"; }; name = Release; diff --git a/Example/Example/RazzleDazzleDemo/AppDelegate.swift b/Example/Example/RazzleDazzleDemo/AppDelegate.swift index 7306fd1..f8a907f 100644 --- a/Example/Example/RazzleDazzleDemo/AppDelegate.swift +++ b/Example/Example/RazzleDazzleDemo/AppDelegate.swift @@ -13,9 +13,8 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - // Override point for customization after application launch. + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool { + return true } diff --git a/Example/Example/RazzleDazzleDemo/Images.xcassets/AppIcon.appiconset/Contents.json b/Example/Example/RazzleDazzleDemo/Images.xcassets/AppIcon.appiconset/Contents.json index 33ec0bc..19882d5 100644 --- a/Example/Example/RazzleDazzleDemo/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/Example/Example/RazzleDazzleDemo/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,15 +1,35 @@ { "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "29x29", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "40x40", "scale" : "2x" }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, { "idiom" : "iphone", "size" : "60x60", @@ -19,6 +39,11 @@ "idiom" : "iphone", "size" : "60x60", "scale" : "3x" + }, + { + "idiom" : "ios-marketing", + "size" : "1024x1024", + "scale" : "1x" } ], "info" : { diff --git a/Example/Example/RazzleDazzleDemo/ViewController.swift b/Example/Example/RazzleDazzleDemo/ViewController.swift index 126f841..1a007b1 100644 --- a/Example/Example/RazzleDazzleDemo/ViewController.swift +++ b/Example/Example/RazzleDazzleDemo/ViewController.swift @@ -98,7 +98,11 @@ class ViewController: AnimatedPagingScrollViewController { private func configureIFTTTPresents() { // Keep IFTTTPresents centered on pages 0 and 1, offset 20 pixels down from the top of the view - NSLayoutConstraint(item: iftttPresents, attribute: .top, relatedBy: .equal, toItem: contentView, attribute: .top, multiplier: 1, constant: 20).isActive = true + if #available(iOS 11.0, *) { + NSLayoutConstraint(item: iftttPresents, attribute: .top, relatedBy: .equal, toItem: contentView.safeAreaLayoutGuide, attribute: .top, multiplier: 1, constant: 20).isActive = true + } else { + NSLayoutConstraint(item: iftttPresents, attribute: .top, relatedBy: .equal, toItem: contentView, attribute: .top, multiplier: 1, constant: 20).isActive = true + } keepView(iftttPresents, onPages: [0,1]) // Hide IFTTTPresents when we get to page 1 @@ -242,7 +246,12 @@ class ViewController: AnimatedPagingScrollViewController { } private func configureSun() { - let sunVerticalConstraint = NSLayoutConstraint(item: sun, attribute: .centerY, relatedBy: .equal, toItem: scrollView, attribute: .top, multiplier: 1, constant: 0) + let sunVerticalConstraint: NSLayoutConstraint + if #available(iOS 11.0, *) { + sunVerticalConstraint = NSLayoutConstraint(item: sun, attribute: .centerY, relatedBy: .equal, toItem: scrollView.safeAreaLayoutGuide, attribute: .top, multiplier: 1, constant: 0) + } else { + sunVerticalConstraint = NSLayoutConstraint(item: sun, attribute: .centerY, relatedBy: .equal, toItem: scrollView, attribute: .top, multiplier: 1, constant: 0) + } sunVerticalConstraint.isActive = true // Move the sun from the right side to the left side between pages 2.5 and 3 @@ -314,7 +323,7 @@ class ViewController: AnimatedPagingScrollViewController { shapeLayer.lineWidth = 4 shapeLayer.miterLimit = 4 shapeLayer.fillColor = nil - shapeLayer.fillRule = kCAFillRuleEvenOdd + shapeLayer.fillRule = CAShapeLayerFillRule.evenOdd return shapeLayer } diff --git a/Example/RazzleDazzle.xcodeproj/project.pbxproj b/Example/RazzleDazzle.xcodeproj/project.pbxproj index f8f567f..1afde9f 100644 --- a/Example/RazzleDazzle.xcodeproj/project.pbxproj +++ b/Example/RazzleDazzle.xcodeproj/project.pbxproj @@ -284,7 +284,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = IFTTT; TargetAttributes = { FACD9C5C1B2A554100AC1614 = { @@ -295,16 +295,17 @@ FACD9C671B2A554100AC1614 = { CreatedOnToolsVersion = 6.3.1; DevelopmentTeamName = "Raphael Cruzeiro (Personal Team)"; - LastSwiftMigration = 0800; + LastSwiftMigration = 1020; }; }; }; buildConfigurationList = FACD9C571B2A554100AC1614 /* Build configuration list for PBXProject "RazzleDazzle" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, + Base, ); mainGroup = FACD9C531B2A554100AC1614; productRefGroup = FACD9C5E1B2A554100AC1614 /* Products */; @@ -398,18 +399,27 @@ 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; 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_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_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; @@ -438,6 +448,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -448,18 +459,27 @@ 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; 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_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_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; @@ -480,6 +500,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -506,7 +527,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -528,7 +549,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -548,7 +569,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -564,7 +585,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "ifttt.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Example/RazzleDazzle.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/RazzleDazzle.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/RazzleDazzle.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/RazzleDazzle.xcodeproj/xcshareddata/xcschemes/RazzleDazzle.xcscheme b/Example/RazzleDazzle.xcodeproj/xcshareddata/xcschemes/RazzleDazzle.xcscheme index bd81817..977ecf1 100644 --- a/Example/RazzleDazzle.xcodeproj/xcshareddata/xcschemes/RazzleDazzle.xcscheme +++ b/Example/RazzleDazzle.xcodeproj/xcshareddata/xcschemes/RazzleDazzle.xcscheme @@ -1,6 +1,6 @@ + + + + + codeCoverageEnabled = "YES" + shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/Example/RazzleDazzle.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Example/RazzleDazzle.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Example/RazzleDazzle.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Example/RazzleDazzleTests/RAZAnimationSpec.swift b/Example/RazzleDazzleTests/RAZAnimationSpec.swift index e56068f..c89907a 100644 --- a/Example/RazzleDazzleTests/RAZAnimationSpec.swift +++ b/Example/RazzleDazzleTests/RAZAnimationSpec.swift @@ -42,7 +42,7 @@ class AnimationSpec: QuickSpec { animator.addAnimation(translationAnimation) let scaleTransform = CGAffineTransform(scaleX: 3, y: 3) - let rotationTransform = CGAffineTransform(rotationAngle: 90 * CGFloat(M_PI / -180.0)) + let rotationTransform = CGAffineTransform(rotationAngle: 90 * CGFloat(Double.pi / -180.0)) let translationTransform = CGAffineTransform(translationX: 5, y: 15) mixedTransform = translationTransform.concatenating(scaleTransform.concatenating(rotationTransform)) diff --git a/Example/RazzleDazzleTests/RAZRotationAnimationSpec.swift b/Example/RazzleDazzleTests/RAZRotationAnimationSpec.swift index 5fb5084..5d33fe6 100644 --- a/Example/RazzleDazzleTests/RAZRotationAnimationSpec.swift +++ b/Example/RazzleDazzleTests/RAZRotationAnimationSpec.swift @@ -50,8 +50,8 @@ class RotationAnimationSpec: QuickSpec { it("should apply changes to the view's rotation transform") { animation[1] = 3 animation[3] = 5 - let radiansOne = 3 * CGFloat(M_PI / -180.0) - let radiansThree = 5 * CGFloat(M_PI / -180.0) + let radiansOne = 3 * CGFloat(Double.pi / -180.0) + let radiansThree = 5 * CGFloat(Double.pi / -180.0) animation.animate(1) expect(view.transform == CGAffineTransform(rotationAngle: radiansOne)).to(beTruthy()) animation.animate(3) diff --git a/Source/AnimatedPagingScrollViewController.swift b/Source/AnimatedPagingScrollViewController.swift index 958ddd2..a0d55d3 100644 --- a/Source/AnimatedPagingScrollViewController.swift +++ b/Source/AnimatedPagingScrollViewController.swift @@ -12,8 +12,8 @@ import UIKit View controller for creating scrolling app intros. Set animation times based on the page number, and this view controller handles calling `animate:` on the `animator`. */ open class AnimatedPagingScrollViewController : UIViewController, UIScrollViewDelegate { - open let scrollView = UIScrollView() - open let contentView = UIView() + public let scrollView = UIScrollView() + public let contentView = UIView() open var animator = Animator() private var scrollViewPageConstraintAnimations = [ScrollViewPageConstraintAnimation]() open var pageWidth : CGFloat { @@ -47,8 +47,16 @@ open class AnimatedPagingScrollViewController : UIViewController, UIScrollViewDe scrollView.translatesAutoresizingMaskIntoConstraints = false contentView.translatesAutoresizingMaskIntoConstraints = false - NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|[scrollView]|", options: [], metrics: nil, views: ["scrollView" : scrollView])) - NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[scrollView]|", options: [], metrics: nil, views: ["scrollView" : scrollView])) + + if #available(iOS 11.0, *) { + scrollView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true + scrollView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor).isActive = true + scrollView.leftAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leftAnchor).isActive = true + scrollView.rightAnchor.constraint(equalTo: view.safeAreaLayoutGuide.rightAnchor).isActive = true + } else { + NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|[scrollView]|", options: [], metrics: nil, views: ["scrollView" : scrollView])) + NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[scrollView]|", options: [], metrics: nil, views: ["scrollView" : scrollView])) + } let scrollViewLeft = NSLayoutConstraint(item: scrollView, attribute: .left, relatedBy: .equal, toItem: contentView, attribute: .left, multiplier: 1, constant: 0) let scrollViewRight = NSLayoutConstraint(item: scrollView, attribute: .right, relatedBy: .equal, toItem: contentView, attribute: .right, multiplier: 1, constant: 0) @@ -58,7 +66,7 @@ open class AnimatedPagingScrollViewController : UIViewController, UIScrollViewDe NSLayoutConstraint.activate([scrollViewLeft, scrollViewRight, scrollViewTop, scrollViewBottom]) let contentViewWidth = NSLayoutConstraint(item: contentView, attribute: .width, relatedBy: .equal, toItem: view, attribute: .width, multiplier: CGFloat(numberOfPages()), constant: 0) - let contentViewHeight = NSLayoutConstraint(item: contentView, attribute: .height, relatedBy: .equal, toItem: view, attribute: .height, multiplier: 1, constant: 0) + let contentViewHeight = NSLayoutConstraint(item: contentView, attribute: .height, relatedBy: .equal, toItem: scrollView, attribute: .height, multiplier: 1, constant: 0) NSLayoutConstraint.activate([contentViewWidth, contentViewHeight]) } @@ -66,6 +74,10 @@ open class AnimatedPagingScrollViewController : UIViewController, UIScrollViewDe open override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) animateCurrentFrame() + + if #available(iOS 11.0, *) { + scrollView.contentSize = CGSize(width: CGFloat(numberOfPages()) * view.frame.width, height: view.frame.height - view.safeAreaInsets.top - view.safeAreaInsets.bottom) + } } open override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { @@ -149,8 +161,8 @@ open class AnimatedPagingScrollViewController : UIViewController, UIScrollViewDe return 2.0 * (offset + page) / CGFloat(numberOfPages()) } - open func layoutAttributeFromRazAttribute(_ razAttribute: HorizontalPositionAttribute) -> NSLayoutAttribute { - var attribute : NSLayoutAttribute + open func layoutAttributeFromRazAttribute(_ razAttribute: HorizontalPositionAttribute) -> NSLayoutConstraint.Attribute { + var attribute : NSLayoutConstraint.Attribute switch razAttribute { case .centerX: attribute = .centerX diff --git a/Source/CubicBezier.swift b/Source/CubicBezier.swift index c2e7f4e..f6f6f4f 100644 --- a/Source/CubicBezier.swift +++ b/Source/CubicBezier.swift @@ -60,7 +60,7 @@ private func CubicBezierBinarySubdivide(_ x: CGFloat, x1: CGFloat, x2: CGFloat) start = currentT } i += 1 - } while (fabs(currentX) > epsilon && i < maxIterations) + } while (abs(currentX) > epsilon && i < maxIterations) return currentT } diff --git a/Source/LayerStrokeEndAnimation.swift b/Source/LayerStrokeEndAnimation.swift index bd89f26..3f3ea04 100644 --- a/Source/LayerStrokeEndAnimation.swift +++ b/Source/LayerStrokeEndAnimation.swift @@ -25,7 +25,7 @@ public class LayerStrokeEndAnimation : Animation, Animatable { NotificationCenter.default.addObserver( self, selector: #selector(LayerStrokeEndAnimation.createStrokeEndAnimation), - name: NSNotification.Name.UIApplicationDidBecomeActive, + name: UIApplication.didBecomeActiveNotification, object: nil) } @@ -54,7 +54,7 @@ public class LayerStrokeEndAnimation : Animation, Animatable { animation.duration = 1 animation.fromValue = 0 animation.toValue = 1 - animation.fillMode = kCAFillModeBoth + animation.fillMode = CAMediaTimingFillMode.both animation.isRemovedOnCompletion = false return animation } diff --git a/Source/LayerStrokeStartAnimation.swift b/Source/LayerStrokeStartAnimation.swift index 42ef7b5..6b140ad 100644 --- a/Source/LayerStrokeStartAnimation.swift +++ b/Source/LayerStrokeStartAnimation.swift @@ -24,7 +24,7 @@ public class LayerStrokeStartAnimation : Animation, Animatable { NotificationCenter.default.addObserver( self, selector: #selector(LayerStrokeStartAnimation.createStrokeStartAnimation), - name: NSNotification.Name.UIApplicationDidBecomeActive, + name: UIApplication.didBecomeActiveNotification, object: nil) } @@ -53,7 +53,7 @@ public class LayerStrokeStartAnimation : Animation, Animatable { animation.duration = 1 animation.fromValue = 0 animation.toValue = 1 - animation.fillMode = kCAFillModeBoth + animation.fillMode = CAMediaTimingFillMode.both animation.isRemovedOnCompletion = false return animation } diff --git a/Source/PathPositionAnimation.swift b/Source/PathPositionAnimation.swift index b8ee893..4bdc71d 100644 --- a/Source/PathPositionAnimation.swift +++ b/Source/PathPositionAnimation.swift @@ -19,7 +19,7 @@ public class PathPositionAnimation : Animation, Animatable { } } private let animationKey = "PathPosition" - public var rotationMode : String? = kCAAnimationRotateAuto { + public var rotationMode : String? = CAAnimationRotationMode.rotateAuto.rawValue { didSet { createKeyframeAnimation() } @@ -35,7 +35,7 @@ public class PathPositionAnimation : Animation, Animatable { NotificationCenter.default.addObserver( self, selector: #selector(PathPositionAnimation.createKeyframeAnimation), - name: NSNotification.Name.UIApplicationDidBecomeActive, + name: UIApplication.didBecomeActiveNotification, object: nil) } @@ -66,9 +66,9 @@ public class PathPositionAnimation : Animation, Animatable { animation.duration = 1 animation.isAdditive = true animation.repeatCount = Float.infinity - animation.calculationMode = kCAAnimationPaced - animation.rotationMode = rotationMode - animation.fillMode = kCAFillModeBoth + animation.calculationMode = CAAnimationCalculationMode.paced + animation.rotationMode = rotationMode.map { CAAnimationRotationMode(rawValue: $0) } + animation.fillMode = CAMediaTimingFillMode.both animation.isRemovedOnCompletion = false return animation } diff --git a/Source/RotationAnimation.swift b/Source/RotationAnimation.swift index 57e9d4d..096e9b3 100644 --- a/Source/RotationAnimation.swift +++ b/Source/RotationAnimation.swift @@ -21,7 +21,7 @@ public class RotationAnimation : Animation, Animatable { public func animate(_ time: CGFloat) { if !hasKeyframes() {return} let degrees = self[time] - let radians = degrees * CGFloat(M_PI / -180.0) + let radians = degrees * CGFloat(Double.pi / -180.0) let rotationTransform = CGAffineTransform(rotationAngle: radians) view.rotationTransform = rotationTransform var newTransform = rotationTransform diff --git a/Source/UIView+Transform.swift b/Source/UIView+Transform.swift index 68c3a11..e32ae21 100644 --- a/Source/UIView+Transform.swift +++ b/Source/UIView+Transform.swift @@ -22,7 +22,7 @@ internal extension UIView { static var viewExtension = "ViewTranslationExtension" } - internal var rotationTransform: CGAffineTransform? { + var rotationTransform: CGAffineTransform? { get { return getAssociatedObject(self, associativeKey: &RotationTransformAssociatedKey.viewExtension) } @@ -34,7 +34,7 @@ internal extension UIView { } } - internal var scaleTransform: CGAffineTransform? { + var scaleTransform: CGAffineTransform? { get { return getAssociatedObject(self, associativeKey: &ScaleTransformAssociatedKey.viewExtension) } @@ -46,7 +46,7 @@ internal extension UIView { } } - internal var translationTransform: CGAffineTransform? { + var translationTransform: CGAffineTransform? { get { return getAssociatedObject(self, associativeKey: &TranslationTransformAssociatedKey.viewExtension) }