diff --git a/Examples/Simple/.DS_Store b/Examples/Simple/.DS_Store index 805117f..e6dec5c 100644 Binary files a/Examples/Simple/.DS_Store and b/Examples/Simple/.DS_Store differ diff --git a/Examples/Simple/SSASideMenuExample.xcodeproj/project.pbxproj b/Examples/Simple/SSASideMenuExample.xcodeproj/project.pbxproj index 0d4d336..01d170c 100755 --- a/Examples/Simple/SSASideMenuExample.xcodeproj/project.pbxproj +++ b/Examples/Simple/SSASideMenuExample.xcodeproj/project.pbxproj @@ -177,9 +177,12 @@ TargetAttributes = { DC4C1A8B1AA7461E00ACD446 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; + ProvisioningStyle = Manual; }; DC4C1AA01AA7461E00ACD446 = { CreatedOnToolsVersion = 6.1.1; + LastSwiftMigration = 0800; TestTargetID = DC4C1A8B1AA7461E00ACD446; }; }; @@ -338,13 +341,14 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; INFOPLIST_FILE = SSASideMenuExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -354,12 +358,13 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; CLANG_ENABLE_MODULES = YES; - CODE_SIGN_IDENTITY = "iPhone Developer"; + CODE_SIGN_IDENTITY = ""; INFOPLIST_FILE = SSASideMenuExample/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -379,6 +384,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SSASideMenuExample.app/SSASideMenuExample"; }; name = Debug; @@ -395,6 +401,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "SebastianAndersen.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SSASideMenuExample.app/SSASideMenuExample"; }; name = Release; diff --git a/Examples/Simple/SSASideMenuExample.xcodeproj/project.xcworkspace/xcuserdata/sairam.xcuserdatad/UserInterfaceState.xcuserstate b/Examples/Simple/SSASideMenuExample.xcodeproj/project.xcworkspace/xcuserdata/sairam.xcuserdatad/UserInterfaceState.xcuserstate new file mode 100644 index 0000000..5480378 Binary files /dev/null and b/Examples/Simple/SSASideMenuExample.xcodeproj/project.xcworkspace/xcuserdata/sairam.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Examples/Simple/SSASideMenuExample.xcodeproj/xcuserdata/sairam.xcuserdatad/xcschemes/SSASideMenuExample.xcscheme b/Examples/Simple/SSASideMenuExample.xcodeproj/xcuserdata/sairam.xcuserdatad/xcschemes/SSASideMenuExample.xcscheme new file mode 100644 index 0000000..bb6202a --- /dev/null +++ b/Examples/Simple/SSASideMenuExample.xcodeproj/xcuserdata/sairam.xcuserdatad/xcschemes/SSASideMenuExample.xcscheme @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/Simple/SSASideMenuExample.xcodeproj/xcuserdata/sairam.xcuserdatad/xcschemes/xcschememanagement.plist b/Examples/Simple/SSASideMenuExample.xcodeproj/xcuserdata/sairam.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 0000000..42b5f8a --- /dev/null +++ b/Examples/Simple/SSASideMenuExample.xcodeproj/xcuserdata/sairam.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + SSASideMenuExample.xcscheme + + orderHint + 0 + + + SuppressBuildableAutocreation + + DC4C1A8B1AA7461E00ACD446 + + primary + + + DC4C1AA01AA7461E00ACD446 + + primary + + + + + diff --git a/Examples/Simple/SSASideMenuExample/AppDelegate.swift b/Examples/Simple/SSASideMenuExample/AppDelegate.swift index ca2a148..9aea2f1 100755 --- a/Examples/Simple/SSASideMenuExample/AppDelegate.swift +++ b/Examples/Simple/SSASideMenuExample/AppDelegate.swift @@ -13,9 +13,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, SSASideMenuDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - window = UIWindow(frame: UIScreen.mainScreen().bounds) + window = UIWindow(frame: UIScreen.main().bounds) //MARK : Setup SSASideMenu @@ -23,7 +23,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate, SSASideMenuDelegate { sideMenu.backgroundImage = UIImage(named: "Background.jpg") sideMenu.configure(SSASideMenu.MenuViewEffect(fade: true, scale: true, scaleBackground: false)) sideMenu.configure(SSASideMenu.ContentViewEffect(alpha: 1.0, scale: 0.7)) - sideMenu.configure(SSASideMenu.ContentViewShadow(enabled: true, color: UIColor.blackColor(), opacity: 0.6, radius: 6.0)) + sideMenu.configure(SSASideMenu.ContentViewShadow(enabled: true, color: UIColor.black(), opacity: 0.6, radius: 6.0)) sideMenu.delegate = self window?.rootViewController = sideMenu @@ -32,22 +32,22 @@ class AppDelegate: UIResponder, UIApplicationDelegate, SSASideMenuDelegate { return true } - func sideMenuWillShowMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) { + func sideMenuWillShowMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) { print("Will Show \(menuViewController)") } - func sideMenuDidShowMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) { + func sideMenuDidShowMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) { print("Did Show \(menuViewController)") } - func sideMenuDidHideMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) { + func sideMenuDidHideMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) { print("Did Hide \(menuViewController)") } - func sideMenuWillHideMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) { + func sideMenuWillHideMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) { print("Will Hide \(menuViewController)") } - func sideMenuDidRecognizePanGesture(sideMenu: SSASideMenu, recongnizer: UIPanGestureRecognizer) { + func sideMenuDidRecognizePanGesture(_ sideMenu: SSASideMenu, recongnizer: UIPanGestureRecognizer) { print("Did Recognize PanGesture \(recongnizer)") } diff --git a/Examples/Simple/SSASideMenuExample/FirstViewController.swift b/Examples/Simple/SSASideMenuExample/FirstViewController.swift index 3ef731c..6bf61bb 100755 --- a/Examples/Simple/SSASideMenuExample/FirstViewController.swift +++ b/Examples/Simple/SSASideMenuExample/FirstViewController.swift @@ -13,10 +13,10 @@ class FirstViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor.whiteColor() + view.backgroundColor = UIColor.white() title = "Home" - navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Left", style: .Plain, target: self, action: #selector(SSASideMenu.presentLeftMenuViewController)) - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Right", style: .Plain, target: self, action: #selector(SSASideMenu.presentRightMenuViewController)) + navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Left", style: .plain, target: self, action: #selector(SSASideMenu.presentLeftMenuViewController)) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Right", style: .plain, target: self, action: #selector(SSASideMenu.presentRightMenuViewController)) } diff --git a/Examples/Simple/SSASideMenuExample/LeftMenuViewController.swift b/Examples/Simple/SSASideMenuExample/LeftMenuViewController.swift index 6b552d4..cfbfffe 100755 --- a/Examples/Simple/SSASideMenuExample/LeftMenuViewController.swift +++ b/Examples/Simple/SSASideMenuExample/LeftMenuViewController.swift @@ -15,18 +15,18 @@ class LeftMenuViewController: UIViewController { let tableView = UITableView() tableView.delegate = self tableView.dataSource = self - tableView.separatorStyle = .None - tableView.frame = CGRectMake(20, (self.view.frame.size.height - 54 * 5) / 2.0, self.view.frame.size.width, 54 * 5) - tableView.autoresizingMask = [.FlexibleTopMargin, .FlexibleBottomMargin, .FlexibleWidth] - tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") - tableView.opaque = false - tableView.backgroundColor = UIColor.clearColor() + tableView.separatorStyle = .none + tableView.frame = CGRect(x: 20,y: (self.view.frame.size.height - 54 * 5) / 2.0,width: self.view.frame.size.width,height: 54 * 5) + tableView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleWidth] + tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") + tableView.isOpaque = false + tableView.backgroundColor = UIColor.clear() tableView.backgroundView = nil tableView.bounces = false return tableView }() - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -34,7 +34,7 @@ class LeftMenuViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor.clearColor() + view.backgroundColor = UIColor.clear() view.addSubview(tableView) } @@ -53,38 +53,38 @@ class LeftMenuViewController: UIViewController { extension LeftMenuViewController: UITableViewDelegate, UITableViewDataSource { - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 5 } - func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: (IndexPath)) -> CGFloat { return 54 } - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) + let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) let titles: [String] = ["Home", "Calendar", "Profile", "Settings", "Log Out"] let images: [String] = ["IconHome", "IconCalendar", "IconProfile", "IconSettings", "IconEmpty"] - cell.backgroundColor = UIColor.clearColor() + cell.backgroundColor = UIColor.clear() cell.textLabel?.font = UIFont(name: "HelveticaNeue", size: 21) - cell.textLabel?.textColor = UIColor.whiteColor() + cell.textLabel?.textColor = UIColor.white() cell.textLabel?.text = titles[indexPath.row] - cell.selectionStyle = .None + cell.selectionStyle = .none cell.imageView?.image = UIImage(named: images[indexPath.row]) return cell } - func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) - switch indexPath.row { + switch (indexPath as NSIndexPath).row { case 0: sideMenuViewController?.contentViewController = UINavigationController(rootViewController: FirstViewController()) diff --git a/Examples/Simple/SSASideMenuExample/RightMenuViewController.swift b/Examples/Simple/SSASideMenuExample/RightMenuViewController.swift index 3d46804..0d2838f 100755 --- a/Examples/Simple/SSASideMenuExample/RightMenuViewController.swift +++ b/Examples/Simple/SSASideMenuExample/RightMenuViewController.swift @@ -15,18 +15,18 @@ class RightMenuViewController: UIViewController { let tableView = UITableView() tableView.delegate = self tableView.dataSource = self - tableView.separatorStyle = .None - tableView.frame = CGRectMake(180, (self.view.frame.size.height - 54 * 2) / 2.0, self.view.frame.size.width, 54 * 2) - tableView.autoresizingMask = [.FlexibleTopMargin, .FlexibleBottomMargin, .FlexibleWidth] - tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell") - tableView.opaque = false - tableView.backgroundColor = UIColor.clearColor() + tableView.separatorStyle = .none + tableView.frame = CGRect(x: 180,y: (self.view.frame.size.height - 54 * 2) / 2.0,width: self.view.frame.size.width,height: 54 * 2) + tableView.autoresizingMask = [.flexibleTopMargin, .flexibleBottomMargin, .flexibleWidth] + tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell") + tableView.isOpaque = false + tableView.backgroundColor = UIColor.clear() tableView.backgroundView = nil tableView.bounces = false return tableView }() - override func viewDidAppear(animated: Bool) { + override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) @@ -34,7 +34,7 @@ class RightMenuViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor.clearColor() + view.backgroundColor = UIColor.clear() view.addSubview(tableView) } @@ -53,36 +53,36 @@ class RightMenuViewController: UIViewController { extension RightMenuViewController: UITableViewDelegate, UITableViewDataSource { - func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 2 } - func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat { + func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 54 } - func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { + func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) + let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) let titles: [String] = ["Home", "Calendar"] - cell.backgroundColor = UIColor.clearColor() + cell.backgroundColor = UIColor.clear() cell.textLabel?.font = UIFont(name: "HelveticaNeue", size: 21) - cell.textLabel?.textColor = UIColor.whiteColor() - cell.textLabel?.text = titles[indexPath.row] - cell.selectionStyle = .None + cell.textLabel?.textColor = UIColor.white() + cell.textLabel?.text = titles[(indexPath as NSIndexPath).row] + cell.selectionStyle = .none return cell } - func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { + func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { - tableView.deselectRowAtIndexPath(indexPath, animated: true) + tableView.deselectRow(at: indexPath, animated: true) - switch indexPath.row { + switch (indexPath as NSIndexPath).row { case 0: sideMenuViewController?.contentViewController = UINavigationController(rootViewController: FirstViewController()) diff --git a/Examples/Simple/SSASideMenuExample/SSASideMenu.swift b/Examples/Simple/SSASideMenuExample/SSASideMenu.swift index 456ff55..ab1c648 100755 --- a/Examples/Simple/SSASideMenuExample/SSASideMenu.swift +++ b/Examples/Simple/SSASideMenuExample/SSASideMenu.swift @@ -17,8 +17,8 @@ extension UIViewController { } } - private func getSideViewController(viewController: UIViewController) -> SSASideMenu? { - if let parent = viewController.parentViewController { + private func getSideViewController(_ viewController: UIViewController) -> SSASideMenu? { + if let parent = viewController.parent { if parent is SSASideMenu { return parent as? SSASideMenu }else { @@ -42,46 +42,46 @@ extension UIViewController { @objc protocol SSASideMenuDelegate { - optional func sideMenuDidRecognizePanGesture(sideMenu: SSASideMenu, recongnizer: UIPanGestureRecognizer) - optional func sideMenuWillShowMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) - optional func sideMenuDidShowMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) - optional func sideMenuWillHideMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) - optional func sideMenuDidHideMenuViewController(sideMenu: SSASideMenu, menuViewController: UIViewController) + @objc optional func sideMenuDidRecognizePanGesture(_ sideMenu: SSASideMenu, recongnizer: UIPanGestureRecognizer) + @objc optional func sideMenuWillShowMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) + @objc optional func sideMenuDidShowMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) + @objc optional func sideMenuWillHideMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) + @objc optional func sideMenuDidHideMenuViewController(_ sideMenu: SSASideMenu, menuViewController: UIViewController) } class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { enum SSASideMenuPanDirection: Int { - case Edge = 0 - case EveryWhere = 1 + case edge = 0 + case everyWhere = 1 } enum SSASideMenuType: Int { - case Scale = 0 - case Slip = 1 + case scale = 0 + case slip = 1 } enum SSAStatusBarStyle: Int { - case Hidden = 0 - case Black = 1 - case Light = 2 + case hidden = 0 + case black = 1 + case light = 2 } private enum SSASideMenuSide: Int { - case Left = 0 - case Right = 1 + case left = 0 + case right = 1 } struct ContentViewShadow { var enabled: Bool = true - var color: UIColor = UIColor.blackColor() - var offset: CGSize = CGSizeZero + var color: UIColor = UIColor.black() + var offset: CGSize = CGSize.zero var opacity: Float = 0.4 var radius: Float = 8.0 - init(enabled: Bool = true, color: UIColor = UIColor.blackColor(), offset: CGSize = CGSizeZero, opacity: Float = 0.4, radius: Float = 8.0) { + init(enabled: Bool = true, color: UIColor = UIColor.black(), offset: CGSize = CGSize.zero, opacity: Float = 0.4, radius: Float = 8.0) { self.enabled = false self.color = color @@ -98,9 +98,9 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { var scaleBackground: Bool = true var parallaxEnabled: Bool = true var bouncesHorizontally: Bool = true - var statusBarStyle: SSAStatusBarStyle = .Black + var statusBarStyle: SSAStatusBarStyle = .black - init(fade: Bool = true, scale: Bool = true, scaleBackground: Bool = true, parallaxEnabled: Bool = true, bouncesHorizontally: Bool = true, statusBarStyle: SSAStatusBarStyle = .Black) { + init(fade: Bool = true, scale: Bool = true, scaleBackground: Bool = true, parallaxEnabled: Bool = true, bouncesHorizontally: Bool = true, statusBarStyle: SSAStatusBarStyle = .black) { self.fade = fade self.scale = scale @@ -137,14 +137,14 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { var animationDuration: Float = 0.35 var panGestureEnabled: Bool = true - var panDirection: SSASideMenuPanDirection = .Edge - var type: SSASideMenuType = .Scale + var panDirection: SSASideMenuPanDirection = .edge + var type: SSASideMenuType = .scale var panMinimumOpenThreshold: UInt = 60 - var menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5) - var backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7) + var menuViewControllerTransformation: CGAffineTransform = CGAffineTransform(scaleX: 1.5, y: 1.5) + var backgroundTransformation: CGAffineTransform = CGAffineTransform(scaleX: 1.7, y: 1.7) var endAllEditing: Bool = false - init(animationDuration: Float = 0.35, panGestureEnabled: Bool = true, panDirection: SSASideMenuPanDirection = .Edge, type: SSASideMenuType = .Scale, panMinimumOpenThreshold: UInt = 60, menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5), backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7), endAllEditing: Bool = false) { + init(animationDuration: Float = 0.35, panGestureEnabled: Bool = true, panDirection: SSASideMenuPanDirection = .edge, type: SSASideMenuType = .scale, panMinimumOpenThreshold: UInt = 60, menuViewControllerTransformation: CGAffineTransform = CGAffineTransform(scaleX: 1.5, y: 1.5), backgroundTransformation: CGAffineTransform = CGAffineTransform(scaleX: 1.7, y: 1.7), endAllEditing: Bool = false) { self.animationDuration = animationDuration self.panGestureEnabled = panGestureEnabled @@ -157,7 +157,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { } } - func configure(configuration: MenuViewEffect) { + func configure(_ configuration: MenuViewEffect) { fadeMenuView = configuration.fade scaleMenuView = configuration.scale scaleBackgroundImageView = configuration.scaleBackground @@ -165,7 +165,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { bouncesHorizontally = configuration.bouncesHorizontally } - func configure(configuration: ContentViewShadow) { + func configure(_ configuration: ContentViewShadow) { contentViewShadowEnabled = configuration.enabled contentViewShadowColor = configuration.color contentViewShadowOffset = configuration.offset @@ -173,7 +173,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { contentViewShadowRadius = configuration.radius } - func configure(configuration: ContentViewEffect) { + func configure(_ configuration: ContentViewEffect) { contentViewScaleValue = configuration.scale contentViewFadeOutAlpha = configuration.alpha contentViewInLandscapeOffsetCenterX = configuration.landscapeOffsetX @@ -182,7 +182,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { parallaxContentMaximumRelativeValue = configuration.maxParallaxContentRelativeValue } - func configure(configuration: SideMenuOptions) { + func configure(_ configuration: SideMenuOptions) { animationDuration = configuration.animationDuration panGestureEnabled = configuration.panGestureEnabled panDirection = configuration.panDirection @@ -206,7 +206,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { @IBInspectable var bouncesHorizontally: Bool = true // MARK : Public Properties: MenuView - @IBInspectable var statusBarStyle: SSAStatusBarStyle = .Black + @IBInspectable var statusBarStyle: SSAStatusBarStyle = .black // MARK : Private Properties: ContentView @IBInspectable var contentViewScaleValue: Float = 0.7 @@ -222,19 +222,19 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { // MARK : Private Properties: Shadow for ContentView @IBInspectable var contentViewShadowEnabled: Bool = true - @IBInspectable var contentViewShadowColor: UIColor = UIColor.blackColor() - @IBInspectable var contentViewShadowOffset: CGSize = CGSizeZero + @IBInspectable var contentViewShadowColor: UIColor = UIColor.black() + @IBInspectable var contentViewShadowOffset: CGSize = CGSize.zero @IBInspectable var contentViewShadowOpacity: Float = 0.4 @IBInspectable var contentViewShadowRadius: Float = 8.0 // MARK : Public Properties: SideMenu @IBInspectable var animationDuration: Float = 0.35 @IBInspectable var panGestureEnabled: Bool = true - @IBInspectable var panDirection: SSASideMenuPanDirection = .Edge - @IBInspectable var type: SSASideMenuType = .Scale + @IBInspectable var panDirection: SSASideMenuPanDirection = .edge + @IBInspectable var type: SSASideMenuType = .scale @IBInspectable var panMinimumOpenThreshold: UInt = 60 - @IBInspectable var menuViewControllerTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.5, 1.5) - @IBInspectable var backgroundTransformation: CGAffineTransform = CGAffineTransformMakeScale(1.7, 1.7) + @IBInspectable var menuViewControllerTransformation: CGAffineTransform = CGAffineTransform(scaleX: 1.5, y: 1.5) + @IBInspectable var backgroundTransformation: CGAffineTransform = CGAffineTransform(scaleX: 1.7, y: 1.7) // MARK : Internal Private Properties @@ -288,7 +288,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { hideViewController(controller) } setupMenuViewControllerMotionEffects() - view.bringSubviewToFront(contentViewContainer) + view.bringSubview(toFront: contentViewContainer) } } @@ -301,7 +301,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { hideViewController(controller) } setupMenuViewControllerMotionEffects() - view.bringSubviewToFront(contentViewContainer) + view.bringSubview(toFront: contentViewContainer) } } @@ -312,7 +312,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { super.init(coder: aDecoder) } - override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) { + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) } @@ -357,18 +357,18 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if let viewController = rightMenuViewController { - showMenuViewController(.Right, menuViewController: viewController) + showMenuViewController(.right, menuViewController: viewController) - UIView.animateWithDuration(NSTimeInterval(animationDuration), animations: {[unowned self] () -> Void in + UIView.animate(withDuration: TimeInterval(animationDuration), animations: {[unowned self] () -> Void in - self.animateMenuViewController(.Right) + self.animateMenuViewController(.right) self.menuViewContainer.alpha = 1 self.contentViewContainer.alpha = CGFloat(self.contentViewFadeOutAlpha) }, completion: {[unowned self] (Bool) -> Void in - self.animateMenuViewControllerCompletion(.Right, menuViewController: viewController) + self.animateMenuViewControllerCompletion(.right, menuViewController: viewController) }) statusBarNeedsAppearanceUpdate() } @@ -379,17 +379,17 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if let viewController = leftMenuViewController { - showMenuViewController(.Left, menuViewController: viewController) + showMenuViewController(.left, menuViewController: viewController) - UIView.animateWithDuration(NSTimeInterval(animationDuration), animations: {[unowned self] () -> Void in + UIView.animate(withDuration: TimeInterval(animationDuration), animations: {[unowned self] () -> Void in - self.animateMenuViewController(.Left) + self.animateMenuViewController(.left) self.menuViewContainer.alpha = 1 self.contentViewContainer.alpha = CGFloat(self.contentViewFadeOutAlpha) }, completion: {[unowned self] (Bool) -> Void in - self.animateMenuViewControllerCompletion(.Left, menuViewController: viewController) + self.animateMenuViewControllerCompletion(.left, menuViewController: viewController) }) statusBarNeedsAppearanceUpdate() @@ -397,17 +397,17 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { } } - private func showMenuViewController(side: SSASideMenuSide, menuViewController: UIViewController) { + private func showMenuViewController(_ side: SSASideMenuSide, menuViewController: UIViewController) { - menuViewController.view.hidden = false + menuViewController.view.isHidden = false switch side { - case .Left: + case .left: leftMenuViewController?.beginAppearanceTransition(true, animated: true) - rightMenuViewController?.view.hidden = true - case .Right: + rightMenuViewController?.view.isHidden = true + case .right: rightMenuViewController?.beginAppearanceTransition(true, animated: true) - leftMenuViewController?.view.hidden = true + leftMenuViewController?.view.isHidden = true } if endAllEditing { @@ -420,46 +420,46 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { setupContentViewShadow() resetContentViewScale() - UIApplication.sharedApplication().beginIgnoringInteractionEvents() + UIApplication.shared().beginIgnoringInteractionEvents() } - private func animateMenuViewController(side: SSASideMenuSide) { + private func animateMenuViewController(_ side: SSASideMenuSide) { - if type == .Scale { - contentViewContainer.transform = CGAffineTransformMakeScale(CGFloat(contentViewScaleValue), CGFloat(contentViewScaleValue)) + if type == .scale { + contentViewContainer.transform = CGAffineTransform(scaleX: CGFloat(contentViewScaleValue), y: CGFloat(contentViewScaleValue)) } else { - contentViewContainer.transform = CGAffineTransformIdentity + contentViewContainer.transform = CGAffineTransform.identity } - if side == .Left { - let centerXLandscape = CGFloat(contentViewInLandscapeOffsetCenterX) + (iOS8 ? CGFloat(CGRectGetWidth(view.frame)) : CGFloat(CGRectGetHeight(view.frame))) - let centerXPortrait = CGFloat(contentViewInPortraitOffsetCenterX) + CGFloat(CGRectGetWidth(view.frame)) + if side == .left { + let centerXLandscape = CGFloat(contentViewInLandscapeOffsetCenterX) + (iOS8 ? CGFloat(view.frame.width) : CGFloat(view.frame.height)) + let centerXPortrait = CGFloat(contentViewInPortraitOffsetCenterX) + CGFloat(view.frame.width) - let centerX = UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) ? centerXLandscape : centerXPortrait + let centerX = UIInterfaceOrientationIsLandscape(UIApplication.shared().statusBarOrientation) ? centerXLandscape : centerXPortrait - contentViewContainer.center = CGPointMake(centerX, contentViewContainer.center.y) + contentViewContainer.center = CGPoint(x: centerX, y: contentViewContainer.center.y) } else { let centerXLandscape = -CGFloat(self.contentViewInLandscapeOffsetCenterX) let centerXPortrait = CGFloat(-self.contentViewInPortraitOffsetCenterX) - let centerX = UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) ? centerXLandscape : centerXPortrait + let centerX = UIInterfaceOrientationIsLandscape(UIApplication.shared().statusBarOrientation) ? centerXLandscape : centerXPortrait - contentViewContainer.center = CGPointMake(centerX, contentViewContainer.center.y) + contentViewContainer.center = CGPoint(x: centerX, y: contentViewContainer.center.y) } - menuViewContainer.transform = CGAffineTransformIdentity + menuViewContainer.transform = CGAffineTransform.identity if scaleBackgroundImageView { if let _ = backgroundImage { - backgroundImageView.transform = CGAffineTransformIdentity + backgroundImageView.transform = CGAffineTransform.identity } } } - private func animateMenuViewControllerCompletion(side: SSASideMenuSide, menuViewController: UIViewController) { + private func animateMenuViewControllerCompletion(_ side: SSASideMenuSide, menuViewController: UIViewController) { if !visible { self.delegate?.sideMenuDidShowMenuViewController?(self, menuViewController: menuViewController) @@ -468,10 +468,10 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { visible = true switch side { - case .Left: + case .left: leftMenuViewController?.endAppearanceTransition() leftMenuVisible = true - case .Right: + case .right: if contentViewContainer.frame.size.width == view.bounds.size.width && contentViewContainer.frame.size.height == view.bounds.size.height && contentViewContainer.frame.origin.x == 0 && @@ -483,18 +483,18 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { } - UIApplication.sharedApplication().endIgnoringInteractionEvents() + UIApplication.shared().endIgnoringInteractionEvents() setupContentViewControllerMotionEffects() } - private func presentMenuViewContainerWithMenuViewController(menuViewController: UIViewController?) { + private func presentMenuViewContainerWithMenuViewController(_ menuViewController: UIViewController?) { - menuViewContainer.transform = CGAffineTransformIdentity + menuViewContainer.transform = CGAffineTransform.identity menuViewContainer.frame = view.bounds if scaleBackgroundImageView { if backgroundImage != nil { - backgroundImageView.transform = CGAffineTransformIdentity + backgroundImageView.transform = CGAffineTransform.identity backgroundImageView.frame = view.bounds backgroundImageView.transform = backgroundTransformation } @@ -511,7 +511,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { } - private func hideMenuViewController(animated: Bool) { + private func hideMenuViewController(_ animated: Bool) { let isRightMenuVisible: Bool = rightMenuVisible @@ -538,7 +538,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { let animationsClosure: () -> () = {[unowned self] () -> () in - self.contentViewContainer.transform = CGAffineTransformIdentity + self.contentViewContainer.transform = CGAffineTransform.identity self.contentViewContainer.frame = self.view.bounds if self.scaleMenuView { @@ -575,15 +575,15 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if animated { - UIApplication.sharedApplication().beginIgnoringInteractionEvents() - UIView.animateWithDuration(NSTimeInterval(animationDuration), animations: { () -> Void in + UIApplication.shared().beginIgnoringInteractionEvents() + UIView.animate(withDuration: TimeInterval(animationDuration), animations: { () -> Void in animationsClosure() }, completion: { (Bool) -> Void in completionClosure() - UIApplication.sharedApplication().endIgnoringInteractionEvents() + UIApplication.shared().endIgnoringInteractionEvents() }) }else { @@ -603,14 +603,14 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if iOS8 { if let cntentViewStoryboardID = contentViewStoryboardID { - contentViewController = storyboard?.instantiateViewControllerWithIdentifier(cntentViewStoryboardID) + contentViewController = storyboard?.instantiateViewController(withIdentifier: cntentViewStoryboardID) } if let lftViewStoryboardID = leftMenuViewStoryboardID { - leftMenuViewController = storyboard?.instantiateViewControllerWithIdentifier(lftViewStoryboardID) + leftMenuViewController = storyboard?.instantiateViewController(withIdentifier: lftViewStoryboardID) } if let rghtViewStoryboardID = rightMenuViewStoryboardID { - rightMenuViewController = storyboard?.instantiateViewControllerWithIdentifier(rghtViewStoryboardID) + rightMenuViewController = storyboard?.instantiateViewController(withIdentifier: rghtViewStoryboardID) } } @@ -620,21 +620,21 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { override func viewDidLoad() { super.viewDidLoad() - view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] + view.autoresizingMask = [.flexibleWidth, .flexibleHeight] menuViewContainer.frame = view.bounds; - menuViewContainer.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]; + menuViewContainer.autoresizingMask = [.flexibleWidth, .flexibleHeight]; menuViewContainer.alpha = fadeMenuView ? 0 : 1 contentViewContainer.frame = view.bounds - contentViewContainer.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] + contentViewContainer.autoresizingMask = [.flexibleWidth, .flexibleHeight] setupViewController(contentViewContainer, targetViewController: contentViewController) setupViewController(menuViewContainer, targetViewController: leftMenuViewController) setupViewController(menuViewContainer, targetViewController: rightMenuViewController) if panGestureEnabled { - view.multipleTouchEnabled = false + view.isMultipleTouchEnabled = false let panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(SSASideMenu.panGestureRecognized(_:))) panGestureRecognizer.delegate = self view.addGestureRecognizer(panGestureRecognizer) @@ -645,8 +645,8 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { backgroundImageView.transform = backgroundTransformation } backgroundImageView.frame = view.bounds - backgroundImageView.contentMode = .ScaleAspectFill; - backgroundImageView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]; + backgroundImageView.contentMode = .scaleAspectFill; + backgroundImageView.autoresizingMask = [.flexibleWidth, .flexibleHeight]; view.addSubview(backgroundImageView) } @@ -661,20 +661,20 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { // MARK : Setup - private func setupViewController(targetView: UIView, targetViewController: UIViewController?) { + private func setupViewController(_ targetView: UIView, targetViewController: UIViewController?) { if let viewController = targetViewController { addChildViewController(viewController) viewController.view.frame = view.bounds - viewController.view.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] + viewController.view.autoresizingMask = [.flexibleWidth, .flexibleHeight] targetView.addSubview(viewController.view) - viewController.didMoveToParentViewController(self) + viewController.didMove(toParentViewController: self) } } - private func hideViewController(targetViewController: UIViewController) { - targetViewController.willMoveToParentViewController(nil) + private func hideViewController(_ targetViewController: UIViewController) { + targetViewController.willMove(toParentViewController: nil) targetViewController.view.removeFromSuperview() targetViewController.removeFromParentViewController() } @@ -686,10 +686,10 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if let _ = contentButton.superview { return } else { - contentButton.addTarget(self, action: #selector(SSASideMenu.hideMenuViewController as (SSASideMenu) -> () -> ()), forControlEvents:.TouchUpInside) - contentButton.autoresizingMask = .None + contentButton.addTarget(self, action: #selector(SSASideMenu.hideMenuViewController as (SSASideMenu) -> () -> ()), for:.touchUpInside) + contentButton.autoresizingMask = UIViewAutoresizing() contentButton.frame = contentViewContainer.bounds - contentButton.autoresizingMask = [.FlexibleWidth, .FlexibleHeight] + contentButton.autoresizingMask = [.flexibleWidth, .flexibleHeight] contentButton.tag = 101 contentViewContainer.addSubview(contentButton) } @@ -698,9 +698,9 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { private func statusBarNeedsAppearanceUpdate() { - if self.respondsToSelector(#selector(UIViewController.setNeedsStatusBarAppearanceUpdate)) { + if self.responds(to: #selector(UIViewController.setNeedsStatusBarAppearanceUpdate)) { - UIView.animateWithDuration(0.3, animations: { () -> Void in + UIView.animate(withDuration: 0.3, animations: { () -> Void in self.setNeedsStatusBarAppearanceUpdate() }) } @@ -711,8 +711,8 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if contentViewShadowEnabled { let layer: CALayer = contentViewContainer.layer let path: UIBezierPath = UIBezierPath(rect: layer.bounds) - layer.shadowPath = path.CGPath - layer.shadowColor = contentViewShadowColor.CGColor + layer.shadowPath = path.cgPath + layer.shadowColor = contentViewShadowColor.cgColor layer.shadowOffset = contentViewShadowOffset layer.shadowOpacity = contentViewShadowOpacity layer.shadowRadius = CGFloat(contentViewShadowRadius) @@ -726,19 +726,19 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { let t: CGAffineTransform = contentViewContainer.transform let scale: CGFloat = sqrt(t.a * t.a + t.c * t.c) let frame: CGRect = contentViewContainer.frame - contentViewContainer.transform = CGAffineTransformIdentity - contentViewContainer.transform = CGAffineTransformMakeScale(scale, scale) + contentViewContainer.transform = CGAffineTransform.identity + contentViewContainer.transform = CGAffineTransform(scaleX: scale, y: scale) contentViewContainer.frame = frame } - private func setupUserInteractionForContentButtonAndTargetViewControllerView(contentButtonInteractive: Bool, targetViewControllerViewInteractive: Bool) { + private func setupUserInteractionForContentButtonAndTargetViewControllerView(_ contentButtonInteractive: Bool, targetViewControllerViewInteractive: Bool) { if let viewController = contentViewController { for view in viewController.view.subviews { if view.tag == 101 { - view.userInteractionEnabled = contentButtonInteractive + view.isUserInteractionEnabled = contentButtonInteractive }else { - view.userInteractionEnabled = targetViewControllerViewInteractive + view.isUserInteractionEnabled = targetViewControllerViewInteractive } } } @@ -747,7 +747,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { // MARK : Motion Effects (Private) - private func removeMotionEffects(targetView: UIView) { + private func removeMotionEffects(_ targetView: UIView) { let targetViewMotionEffects = targetView.motionEffects for effect in targetViewMotionEffects { targetView.removeMotionEffect(effect) @@ -761,13 +761,13 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { removeMotionEffects(menuViewContainer) // We need to refer to self in closures! - UIView.animateWithDuration(0.2, animations: { [unowned self] () -> Void in + UIView.animate(withDuration: 0.2, animations: { [unowned self] () -> Void in - let interpolationHorizontal: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.x", type: .TiltAlongHorizontalAxis) + let interpolationHorizontal: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis) interpolationHorizontal.minimumRelativeValue = self.parallaxContentMinimumRelativeValue interpolationHorizontal.maximumRelativeValue = self.parallaxContentMaximumRelativeValue - let interpolationVertical: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.y", type: .TiltAlongVerticalAxis) + let interpolationVertical: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis) interpolationHorizontal.minimumRelativeValue = self.parallaxContentMinimumRelativeValue interpolationHorizontal.maximumRelativeValue = self.parallaxContentMaximumRelativeValue @@ -786,13 +786,13 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { removeMotionEffects(contentViewContainer) // We need to refer to self in closures! - UIView.animateWithDuration(0.2, animations: { [unowned self] () -> Void in + UIView.animate(withDuration: 0.2, animations: { [unowned self] () -> Void in - let interpolationHorizontal: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.x", type: .TiltAlongHorizontalAxis) + let interpolationHorizontal: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis) interpolationHorizontal.minimumRelativeValue = self.parallaxContentMinimumRelativeValue interpolationHorizontal.maximumRelativeValue = self.parallaxContentMaximumRelativeValue - let interpolationVertical: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.y", type: .TiltAlongVerticalAxis) + let interpolationVertical: UIInterpolatingMotionEffect = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis) interpolationHorizontal.minimumRelativeValue = self.parallaxContentMinimumRelativeValue interpolationHorizontal.maximumRelativeValue = self.parallaxContentMaximumRelativeValue @@ -817,38 +817,38 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { } - override func willAnimateRotationToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) { + override func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval) { if visible { menuViewContainer.bounds = view.bounds - contentViewContainer.transform = CGAffineTransformIdentity + contentViewContainer.transform = CGAffineTransform.identity contentViewContainer.frame = view.bounds - if type == .Scale { - contentViewContainer.transform = CGAffineTransformMakeScale(CGFloat(contentViewScaleValue), CGFloat(contentViewScaleValue)) + if type == .scale { + contentViewContainer.transform = CGAffineTransform(scaleX: CGFloat(contentViewScaleValue), y: CGFloat(contentViewScaleValue)) } else { - contentViewContainer.transform = CGAffineTransformIdentity + contentViewContainer.transform = CGAffineTransform.identity } var center: CGPoint if leftMenuVisible { - let centerXLandscape = CGFloat(contentViewInLandscapeOffsetCenterX) + (iOS8 ? CGFloat(CGRectGetWidth(view.frame)) : CGFloat(CGRectGetHeight(view.frame))) - let centerXPortrait = CGFloat(contentViewInPortraitOffsetCenterX) + CGFloat(CGRectGetWidth(view.frame)) + let centerXLandscape = CGFloat(contentViewInLandscapeOffsetCenterX) + (iOS8 ? CGFloat(view.frame.width) : CGFloat(view.frame.height)) + let centerXPortrait = CGFloat(contentViewInPortraitOffsetCenterX) + CGFloat(view.frame.width) - let centerX = UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) ? centerXLandscape : centerXPortrait + let centerX = UIInterfaceOrientationIsLandscape(UIApplication.shared().statusBarOrientation) ? centerXLandscape : centerXPortrait - center = CGPointMake(centerX, contentViewContainer.center.y) + center = CGPoint(x: centerX, y: contentViewContainer.center.y) } else { let centerXLandscape = -CGFloat(self.contentViewInLandscapeOffsetCenterX) let centerXPortrait = CGFloat(-self.contentViewInPortraitOffsetCenterX) - let centerX = UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) ? centerXLandscape : centerXPortrait + let centerX = UIInterfaceOrientationIsLandscape(UIApplication.shared().statusBarOrientation) ? centerXLandscape : centerXPortrait - center = CGPointMake(centerX, contentViewContainer.center.y) + center = CGPoint(x: centerX, y: contentViewContainer.center.y) } contentViewContainer.center = center @@ -866,12 +866,12 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { var style: UIStatusBarStyle switch statusBarStyle { - case .Hidden: - style = .Default - case .Black: - style = .Default - case .Light: - style = .LightContent + case .hidden: + style = .default + case .black: + style = .default + case .light: + style = .lightContent } if visible || contentViewContainer.frame.origin.y <= 0, let cntViewController = contentViewController { @@ -887,7 +887,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { var statusBarHidden: Bool switch statusBarStyle { - case .Hidden: + case .hidden: statusBarHidden = true default: statusBarHidden = false @@ -903,7 +903,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { override func preferredStatusBarUpdateAnimation() -> UIStatusBarAnimation { - var statusBarAnimation: UIStatusBarAnimation = .None + var statusBarAnimation: UIStatusBarAnimation = .none if let cntViewController = contentViewController, leftMenuViewController = leftMenuViewController { @@ -935,21 +935,21 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { // MARK : UIGestureRecognizer Delegate (Private) - func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool { + func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldReceive touch: UITouch) -> Bool { if interactivePopGestureRecognizerEnabled, let viewController = contentViewController as? UINavigationController - where viewController.viewControllers.count > 1 && viewController.interactivePopGestureRecognizer!.enabled { + where viewController.viewControllers.count > 1 && viewController.interactivePopGestureRecognizer!.isEnabled { return false } if gestureRecognizer is UIPanGestureRecognizer && !visible { switch panDirection { - case .EveryWhere: + case .everyWhere: return true - case .Edge: - let point = touch.locationInView(gestureRecognizer.view) + case .edge: + let point = touch.location(in: gestureRecognizer.view) if point.x < 20.0 || point.x > view.frame.size.width - 20.0 { return true } else { return false } } @@ -958,7 +958,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { return true } - func panGestureRecognized(recognizer: UIPanGestureRecognizer) { + func panGestureRecognized(_ recognizer: UIPanGestureRecognizer) { delegate?.sideMenuDidRecognizePanGesture?(self, recongnizer: recognizer) @@ -966,17 +966,17 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { return } - var point: CGPoint = recognizer.translationInView(view) + var point: CGPoint = recognizer.translation(in: view) - if recognizer.state == .Began { + if recognizer.state == .began { setupContentViewShadow() - originalPoint = CGPointMake(contentViewContainer.center.x - CGRectGetWidth(contentViewContainer.bounds) / 2.0, - contentViewContainer.center.y - CGRectGetHeight(contentViewContainer.bounds) / 2.0) - menuViewContainer.transform = CGAffineTransformIdentity + originalPoint = CGPoint(x: contentViewContainer.center.x - contentViewContainer.bounds.width / 2.0, + y: contentViewContainer.center.y - contentViewContainer.bounds.height / 2.0) + menuViewContainer.transform = CGAffineTransform.identity if (scaleBackgroundImageView) { - backgroundImageView.transform = CGAffineTransformIdentity + backgroundImageView.transform = CGAffineTransform.identity backgroundImageView.frame = view.bounds } @@ -992,7 +992,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { didNotifyDelegate = false } - if recognizer.state == .Changed { + if recognizer.state == .changed { var delta: CGFloat = 0.0 if visible { @@ -1003,7 +1003,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { delta = min(fabs(delta), 1.6) - var contentViewScale: CGFloat = type == .Scale ? 1 - ((1 - CGFloat(contentViewScaleValue)) * delta) : 1 + var contentViewScale: CGFloat = type == .scale ? 1 - ((1 - CGFloat(contentViewScaleValue)) * delta) : 1 var backgroundViewScale: CGFloat = backgroundTransformation.a - ((backgroundTransformation.a - 1) * delta) var menuViewScale: CGFloat = menuViewControllerTransformation.a - ((menuViewControllerTransformation.a - 1) * delta) @@ -1018,15 +1018,15 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { contentViewContainer.alpha = 1 - (1 - CGFloat(contentViewFadeOutAlpha)) * delta if scaleBackgroundImageView { - backgroundImageView.transform = CGAffineTransformMakeScale(backgroundViewScale, backgroundViewScale) + backgroundImageView.transform = CGAffineTransform(scaleX: backgroundViewScale, y: backgroundViewScale) } if scaleMenuView { - menuViewContainer.transform = CGAffineTransformMakeScale(menuViewScale, menuViewScale) + menuViewContainer.transform = CGAffineTransform(scaleX: menuViewScale, y: menuViewScale) } if scaleBackgroundImageView && backgroundViewScale < 1 { - backgroundImageView.transform = CGAffineTransformIdentity + backgroundImageView.transform = CGAffineTransform.identity } if bouncesHorizontally && visible { @@ -1042,12 +1042,12 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { // Limit size if point.x < 0 { - point.x = max(point.x, -UIScreen.mainScreen().bounds.size.height) + point.x = max(point.x, -UIScreen.main().bounds.size.height) } else { - point.x = min(point.x, UIScreen.mainScreen().bounds.size.height) + point.x = min(point.x, UIScreen.main().bounds.size.height) } - recognizer.setTranslation(point, inView: view) + recognizer.setTranslation(point, in: view) if !didNotifyDelegate { if point.x > 0 && !visible, let viewController = leftMenuViewController { @@ -1062,23 +1062,23 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { if contentViewScale > 1 { let oppositeScale: CGFloat = (1 - (contentViewScale - 1)) - contentViewContainer.transform = CGAffineTransformMakeScale(oppositeScale, oppositeScale) - contentViewContainer.transform = CGAffineTransformTranslate(contentViewContainer.transform, point.x, 0) + contentViewContainer.transform = CGAffineTransform(scaleX: oppositeScale, y: oppositeScale) + contentViewContainer.transform = contentViewContainer.transform.translateBy(x: point.x, y: 0) } else { - contentViewContainer.transform = CGAffineTransformMakeScale(contentViewScale, contentViewScale) - contentViewContainer.transform = CGAffineTransformTranslate(contentViewContainer.transform, point.x, 0) + contentViewContainer.transform = CGAffineTransform(scaleX: contentViewScale, y: contentViewScale) + contentViewContainer.transform = contentViewContainer.transform.translateBy(x: point.x, y: 0) } - leftMenuViewController?.view.hidden = contentViewContainer.frame.origin.x < 0 - rightMenuViewController?.view.hidden = contentViewContainer.frame.origin.x > 0 + leftMenuViewController?.view.isHidden = contentViewContainer.frame.origin.x < 0 + rightMenuViewController?.view.isHidden = contentViewContainer.frame.origin.x > 0 if leftMenuViewController == nil && contentViewContainer.frame.origin.x > 0 { - contentViewContainer.transform = CGAffineTransformIdentity + contentViewContainer.transform = CGAffineTransform.identity contentViewContainer.frame = view.bounds visible = false leftMenuVisible = false } else if self.rightMenuViewController == nil && contentViewContainer.frame.origin.x < 0 { - contentViewContainer.transform = CGAffineTransformIdentity + contentViewContainer.transform = CGAffineTransform.identity contentViewContainer.frame = view.bounds visible = false rightMenuVisible = false @@ -1087,7 +1087,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { statusBarNeedsAppearanceUpdate() } - if recognizer.state == .Ended { + if recognizer.state == .ended { didNotifyDelegate = false if panMinimumOpenThreshold > 0 && @@ -1103,7 +1103,7 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { hideMenuViewController(false) } - else if recognizer.velocityInView(view).x > 0 { + else if recognizer.velocity(in: view).x > 0 { if contentViewContainer.frame.origin.x < 0 { hideMenuViewController() } else if leftMenuViewController != nil { @@ -1122,4 +1122,4 @@ class SSASideMenu: UIViewController, UIGestureRecognizerDelegate { } -} \ No newline at end of file +} diff --git a/Examples/Simple/SSASideMenuExample/SecondViewController.swift b/Examples/Simple/SSASideMenuExample/SecondViewController.swift index 13cb2f4..f32ddff 100755 --- a/Examples/Simple/SSASideMenuExample/SecondViewController.swift +++ b/Examples/Simple/SSASideMenuExample/SecondViewController.swift @@ -13,11 +13,11 @@ class SecondViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - view.backgroundColor = UIColor.whiteColor() + view.backgroundColor = UIColor.white() title = "Calender" - navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Left", style: .Plain, target: self, action: #selector(SSASideMenu.presentLeftMenuViewController)) - navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Right", style: .Plain, target: self, action: #selector(SSASideMenu.presentRightMenuViewController)) + navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Left", style: .plain, target: self, action: #selector(SSASideMenu.presentLeftMenuViewController)) + navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Right", style: .plain, target: self, action: #selector(SSASideMenu.presentRightMenuViewController)) } @@ -28,4 +28,4 @@ class SecondViewController: UIViewController { } -} \ No newline at end of file +} diff --git a/Examples/Simple/SSASideMenuExampleTests/SSASideMenuExampleTests.swift b/Examples/Simple/SSASideMenuExampleTests/SSASideMenuExampleTests.swift index 6f4b25d..ba63f8f 100755 --- a/Examples/Simple/SSASideMenuExampleTests/SSASideMenuExampleTests.swift +++ b/Examples/Simple/SSASideMenuExampleTests/SSASideMenuExampleTests.swift @@ -28,7 +28,7 @@ class SSASideMenuExampleTests: XCTestCase { func testPerformanceExample() { // This is an example of a performance test case. - self.measureBlock() { + self.measure() { // Put the code you want to measure the time of here. } }