From 5eddb11dcad0146dee7af223f69ba5eb674a0802 Mon Sep 17 00:00:00 2001 From: robsonsky1985 Date: Tue, 7 Jul 2020 15:30:16 -0300 Subject: [PATCH] Updated to Swift 5 --- AlertOnboarding.xcodeproj/project.pbxproj | 8 ++++++-- AlertOnboarding/AlertOnboarding.swift | 10 +++++----- AlertOnboarding/AlertPageViewController.swift | 10 +++++----- AlertOnboarding/AppDelegate.swift | 2 +- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/AlertOnboarding.xcodeproj/project.pbxproj b/AlertOnboarding.xcodeproj/project.pbxproj index 4fb1e79..7862824 100644 --- a/AlertOnboarding.xcodeproj/project.pbxproj +++ b/AlertOnboarding.xcodeproj/project.pbxproj @@ -116,6 +116,7 @@ TargetAttributes = { 37845A641D994CBA009B3734 = { CreatedOnToolsVersion = 8.0; + LastSwiftMigration = 1150; ProvisioningStyle = Automatic; }; }; @@ -125,6 +126,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -286,12 +288,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = AlertOnboarding/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cookminute.AlertOnboarding; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -299,12 +302,13 @@ isa = XCBuildConfiguration; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = AlertOnboarding/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cookminute.AlertOnboarding; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/AlertOnboarding/AlertOnboarding.swift b/AlertOnboarding/AlertOnboarding.swift index 060b91e..51a92aa 100644 --- a/AlertOnboarding/AlertOnboarding.swift +++ b/AlertOnboarding/AlertOnboarding.swift @@ -82,8 +82,8 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { //Update Color self.buttonBottom.backgroundColor = colorButtonBottomBackground self.backgroundColor = colorForAlertViewBackground - self.buttonBottom.setTitleColor(colorButtonText, for: UIControlState()) - self.buttonBottom.setTitle(self.titleSkipButton, for: UIControlState()) + self.buttonBottom.setTitleColor(colorButtonText, for: UIControl.State()) + self.buttonBottom.setTitle(self.titleSkipButton, for: UIControl.State()) self.container = AlertPageViewController(arrayOfImage: arrayOfImage, arrayOfTitle: arrayOfTitle, arrayOfDescription: arrayOfDescription, alertView: self) self.container.delegate = self @@ -200,7 +200,7 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { } fileprivate func animateForEnding(){ - UIView.animate(withDuration: 0.2, delay: 0.0, options: UIViewAnimationOptions.curveEaseOut, animations: { + UIView.animate(withDuration: 0.2, delay: 0.0, options: UIView.AnimationOptions.curveEaseOut, animations: { self.alpha = 0.0 }, completion: { (finished: Bool) -> Void in @@ -209,7 +209,7 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { () -> Void in self.background.removeFromSuperview() self.removeFromSuperview() - self.container.removeFromParentViewController() + self.container.removeFromParent() self.container.view.removeFromSuperview() } }) @@ -239,7 +239,7 @@ open class AlertOnboarding: UIView, AlertPageViewDelegate { //MARK: NOTIFICATIONS PROCESS ------------------------------------------ fileprivate func interceptOrientationChange(){ UIDevice.current.beginGeneratingDeviceOrientationNotifications() - NotificationCenter.default.addObserver(self, selector: #selector(AlertOnboarding.onOrientationChange), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(AlertOnboarding.onOrientationChange), name: UIDevice.orientationDidChangeNotification, object: nil) } @objc func onOrientationChange(){ diff --git a/AlertOnboarding/AlertPageViewController.swift b/AlertOnboarding/AlertPageViewController.swift index 06611a0..e4d2d5c 100644 --- a/AlertOnboarding/AlertPageViewController.swift +++ b/AlertOnboarding/AlertPageViewController.swift @@ -53,7 +53,7 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, self.view.backgroundColor = UIColor.clear self.view.addSubview(self.pageController.view) self.view.addSubview(self.pageControl) - self.pageController.didMove(toParentViewController: self) + self.pageController.didMove(toParent: self) } override func viewWillAppear(_ animated: Bool) { @@ -140,9 +140,9 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, if pageControl != nil { pageControl.currentPage = arrayOfImage.count - index! - 1 if pageControl.currentPage == arrayOfImage.count - 1 { - self.alertview.buttonBottom.setTitle(alertview.titleGotItButton, for: UIControlState()) + self.alertview.buttonBottom.setTitle(alertview.titleGotItButton, for: UIControl.State()) } else { - self.alertview.buttonBottom.setTitle(alertview.titleSkipButton, for: UIControlState()) + self.alertview.buttonBottom.setTitle(alertview.titleSkipButton, for: UIControl.State()) } } } @@ -170,7 +170,7 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, } fileprivate func configurePageViewController(){ - self.pageController = UIPageViewController(transitionStyle: UIPageViewControllerTransitionStyle.scroll, navigationOrientation: UIPageViewControllerNavigationOrientation.horizontal, options: nil) + self.pageController = UIPageViewController(transitionStyle: UIPageViewController.TransitionStyle.scroll, navigationOrientation: UIPageViewController.NavigationOrientation.horizontal, options: nil) self.pageController.view.backgroundColor = UIColor.clear if #available(iOS 9.0, *) { @@ -189,7 +189,7 @@ class AlertPageViewController: UIViewController, UIPageViewControllerDataSource, self.viewControllers = [initialViewController!] self.pageController.setViewControllers(viewControllers, direction: .forward, animated: false, completion: nil) - self.addChildViewController(self.pageController) + self.addChild(self.pageController) } //MARK: Called after notification orientation changement diff --git a/AlertOnboarding/AppDelegate.swift b/AlertOnboarding/AppDelegate.swift index 4d7a9c2..20366b2 100644 --- a/AlertOnboarding/AppDelegate.swift +++ b/AlertOnboarding/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true }