diff --git a/FoldingCell/FoldingCell-Demo/AppDelegate.swift b/FoldingCell/FoldingCell-Demo/AppDelegate.swift index 4411678..39a0273 100644 --- a/FoldingCell/FoldingCell-Demo/AppDelegate.swift +++ b/FoldingCell/FoldingCell-Demo/AppDelegate.swift @@ -28,7 +28,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool { + func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool { return true } } diff --git a/FoldingCell/FoldingCell-Demo/MainTableViewController.swift b/FoldingCell/FoldingCell-Demo/MainTableViewController.swift index ad77deb..cb3d3c0 100644 --- a/FoldingCell/FoldingCell-Demo/MainTableViewController.swift +++ b/FoldingCell/FoldingCell-Demo/MainTableViewController.swift @@ -42,7 +42,7 @@ class MainTableViewController: UITableViewController { private func setup() { cellHeights = Array(repeating: Const.closeCellHeight, count: Const.rowsCount) tableView.estimatedRowHeight = Const.closeCellHeight - tableView.rowHeight = UITableViewAutomaticDimension + tableView.rowHeight = UITableView.automaticDimension tableView.backgroundColor = UIColor(patternImage: #imageLiteral(resourceName: "background")) if #available(iOS 10.0, *) { tableView.refreshControl = UIRefreshControl() diff --git a/FoldingCell/FoldingCell.xcodeproj/project.pbxproj b/FoldingCell/FoldingCell.xcodeproj/project.pbxproj index 5b24ec1..6fb874d 100644 --- a/FoldingCell/FoldingCell.xcodeproj/project.pbxproj +++ b/FoldingCell/FoldingCell.xcodeproj/project.pbxproj @@ -318,18 +318,19 @@ TargetAttributes = { 5A0E1C2C21414940006A0374 = { CreatedOnToolsVersion = 9.4; + LastSwiftMigration = 1000; ProvisioningStyle = Automatic; TestTargetID = 9D57F31B1EDC7A6F0004599F; }; 8499D8841D0054A8004B5B37 = { CreatedOnToolsVersion = 7.3.1; DevelopmentTeam = LEAZS7L33U; - LastSwiftMigration = 0830; + LastSwiftMigration = 1000; }; 9D57F31B1EDC7A6F0004599F = { CreatedOnToolsVersion = 8.3.2; DevelopmentTeam = 34MUF9YXTA; - LastSwiftMigration = 0920; + LastSwiftMigration = 1000; ProvisioningStyle = Automatic; }; 9DAA51531EDDBAD700DFC539 = { @@ -508,7 +509,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoldingCell-Demo.app/FoldingCell-Demo"; }; @@ -531,7 +532,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCellDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/FoldingCell-Demo.app/FoldingCell-Demo"; }; @@ -660,7 +661,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -687,7 +688,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.ramotion.FoldingCell; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -712,8 +713,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -734,8 +734,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "ramotion.com.FoldingCell-Demo"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/FoldingCell/FoldingCell/FoldingCell.swift b/FoldingCell/FoldingCell/FoldingCell.swift index d5e1d6a..dab7946 100644 --- a/FoldingCell/FoldingCell/FoldingCell.swift +++ b/FoldingCell/FoldingCell/FoldingCell.swift @@ -93,7 +93,7 @@ open class FoldingCell: UITableViewCell { foregroundView.layer.transform = foregroundView.transform3d() createAnimationView() - contentView.bringSubview(toFront: foregroundView) + contentView.bringSubviewToFront(foregroundView) } func createAnimationItemView() -> [RotatedView] { @@ -309,7 +309,7 @@ open class FoldingCell: UITableViewCell { let durations = durationSequence(.open) var delay: TimeInterval = 0 - var timing = kCAMediaTimingFunctionEaseIn + var timing = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) var from: CGFloat = 0.0 var to: CGFloat = -CGFloat.pi / 2 var hidden = true @@ -326,7 +326,7 @@ open class FoldingCell: UITableViewCell { from = from == 0.0 ? CGFloat.pi / 2 : 0.0 to = to == 0.0 ? -CGFloat.pi / 2 : 0.0 - timing = timing == kCAMediaTimingFunctionEaseIn ? kCAMediaTimingFunctionEaseOut : kCAMediaTimingFunctionEaseIn + timing = timing == convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) ? convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) : convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) hidden = !hidden delay += durations[index] } @@ -360,7 +360,7 @@ open class FoldingCell: UITableViewCell { var durations: [TimeInterval] = durationSequence(.close).reversed() var delay: TimeInterval = 0 - var timing = kCAMediaTimingFunctionEaseIn + var timing = convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) var from: CGFloat = 0.0 var to: CGFloat = CGFloat.pi / 2 var hidden = true @@ -376,7 +376,7 @@ open class FoldingCell: UITableViewCell { to = to == 0.0 ? CGFloat.pi / 2 : 0.0 from = from == 0.0 ? -CGFloat.pi / 2 : 0.0 - timing = timing == kCAMediaTimingFunctionEaseIn ? kCAMediaTimingFunctionEaseOut : kCAMediaTimingFunctionEaseIn + timing = timing == convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) ? convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeOut) : convertFromCAMediaTimingFunctionName(CAMediaTimingFunctionName.easeIn) hidden = !hidden delay += durations[index] } @@ -454,12 +454,12 @@ extension RotatedView: CAAnimationDelegate { func foldingAnimation(_ timing: String, from: CGFloat, to: CGFloat, duration: TimeInterval, delay: TimeInterval, hidden: Bool) { let rotateAnimation = CABasicAnimation(keyPath: Const.transformRotationX) - rotateAnimation.timingFunction = CAMediaTimingFunction(name: timing) + rotateAnimation.timingFunction = CAMediaTimingFunction(name: convertToCAMediaTimingFunctionName(timing)) rotateAnimation.fromValue = from rotateAnimation.toValue = to rotateAnimation.duration = duration rotateAnimation.delegate = self - rotateAnimation.fillMode = kCAFillModeForwards + rotateAnimation.fillMode = CAMediaTimingFillMode.forwards rotateAnimation.isRemovedOnCompletion = false rotateAnimation.beginTime = CACurrentMediaTime() + delay @@ -499,3 +499,13 @@ private extension UIView { return image } } + +// Helper function inserted by Swift 4.2 migrator. +fileprivate func convertFromCAMediaTimingFunctionName(_ input: CAMediaTimingFunctionName) -> String { + return input.rawValue +} + +// Helper function inserted by Swift 4.2 migrator. +fileprivate func convertToCAMediaTimingFunctionName(_ input: String) -> CAMediaTimingFunctionName { + return CAMediaTimingFunctionName(rawValue: input) +} diff --git a/FoldingCell/FoldingCellDemoTests/FoldingCellDemoTests.swift b/FoldingCell/FoldingCellDemoTests/FoldingCellDemoTests.swift index e778984..1142585 100644 --- a/FoldingCell/FoldingCellDemoTests/FoldingCellDemoTests.swift +++ b/FoldingCell/FoldingCellDemoTests/FoldingCellDemoTests.swift @@ -21,7 +21,7 @@ class FoldingCellDemoTests: XCTestCase { let storyboard = UIStoryboard(name: "Main", bundle: nil) let vc = storyboard.instantiateViewController(withIdentifier: "MainTableViewController") as! MainTableViewController _ = vc.view - foldingCell = vc.tableView.dequeueReusableCell(withIdentifier: "FoldingCell", for: IndexPath(row: 0, section: 0)) as! FoldingCell + foldingCell = vc.tableView.dequeueReusableCell(withIdentifier: "FoldingCell", for: IndexPath(row: 0, section: 0)) as? FoldingCell } override func tearDown() {