Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified for Swift 5. #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions AlertOnboarding.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down Expand Up @@ -291,7 +292,7 @@
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;
};
Expand All @@ -304,7 +305,7 @@
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;
};
Expand Down
10 changes: 5 additions & 5 deletions AlertOnboarding/AlertOnboarding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
}
})
Expand Down Expand Up @@ -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(){
Expand Down
10 changes: 5 additions & 5 deletions AlertOnboarding/AlertPageViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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())
}
}
}
Expand Down Expand Up @@ -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, *) {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion AlertOnboarding/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down