From c2b78e0d32a2cf1924a867a112fec9b9a9b4c07b Mon Sep 17 00:00:00 2001 From: Oleg Gorbatchev Date: Fri, 21 Sep 2018 01:20:33 +0200 Subject: [PATCH 1/2] Updated for swift4.2 and fix warning (removed force cast) --- Library/PMAlertAction.swift | 4 ++-- Library/PMAlertController.swift | 16 +++++++--------- PMAlertController.podspec | 2 +- PMAlertController.xcodeproj/project.pbxproj | 8 ++++---- README.md | 14 +++++++------- 5 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Library/PMAlertAction.swift b/Library/PMAlertAction.swift index 23bdd55..9271c84 100644 --- a/Library/PMAlertAction.swift +++ b/Library/PMAlertAction.swift @@ -33,11 +33,11 @@ import UIKit self.action = action self.addTarget(self, action: #selector(PMAlertAction.tapped(_:)), for: .touchUpInside) - self.setTitle(title, for: UIControlState()) + self.setTitle(title, for: UIControl.State()) self.titleLabel?.font = UIFont(name: "Avenir-Heavy", size: 17) self.actionStyle = style - style == .default ? (self.setTitleColor(UIColor(red: 191.0/255.0, green: 51.0/255.0, blue: 98.0/255.0, alpha: 1.0), for: UIControlState())) : (self.setTitleColor(UIColor.gray, for: UIControlState())) + style == .default ? (self.setTitleColor(UIColor(red: 191.0/255.0, green: 51.0/255.0, blue: 98.0/255.0, alpha: 1.0), for: UIControl.State())) : (self.setTitleColor(UIColor.gray, for: UIControl.State())) self.addSeparator() } diff --git a/Library/PMAlertController.swift b/Library/PMAlertController.swift index d778572..99e545e 100755 --- a/Library/PMAlertController.swift +++ b/Library/PMAlertController.swift @@ -47,24 +47,22 @@ import UIKit override open func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name:NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name:NSNotification.Name.UIKeyboardWillHide, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(_:)), name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(_:)), name: UIResponder.keyboardWillHideNotification, object: nil) } open override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) - NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillShow, object: nil) - NotificationCenter.default.removeObserver(self, name: NSNotification.Name.UIKeyboardWillHide, object: nil) + NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil) + NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil) } //MARK: - Initialiser @objc public convenience init(title: String, description: String, image: UIImage?, style: PMAlertControllerStyle) { self.init() - let nib = loadNibAlertController() - if nib != nil{ - self.view = nib![0] as! UIView - } + guard let nib = loadNibAlertController(), let unwrappedView = nib[0] as? UIView else { return } + self.view = unwrappedView self.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext self.modalTransitionStyle = UIModalTransitionStyle.crossDissolve @@ -198,7 +196,7 @@ import UIKit keyboardHasBeenShown = true guard let userInfo = (notification as NSNotification).userInfo else {return} - guard let endKeyBoardFrame = (userInfo[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.minY else {return} + guard let endKeyBoardFrame = (userInfo[UIResponder.keyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.minY else {return} if tempFrameOrigin == nil { tempFrameOrigin = alertView.frame.origin diff --git a/PMAlertController.podspec b/PMAlertController.podspec index b3af3a6..a559bf9 100644 --- a/PMAlertController.podspec +++ b/PMAlertController.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "PMAlertController" - s.version = "3.4.0" + s.version = "3.5.0" s.summary = "PMAlertController is a great and customizable substitute to UIAlertController" s.description = <<-DESC PMAlertController is a small library that allows you to substitute the uncustomizable UIAlertController of Apple, with a beautiful and totally customizable alert that you can use in your iOS app. Enjoy! diff --git a/PMAlertController.xcodeproj/project.pbxproj b/PMAlertController.xcodeproj/project.pbxproj index 3e31d2a..4136ef0 100755 --- a/PMAlertController.xcodeproj/project.pbxproj +++ b/PMAlertController.xcodeproj/project.pbxproj @@ -538,7 +538,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -556,7 +556,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -623,7 +623,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -647,7 +647,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/README.md b/README.md index f64c52f..a6c913b 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@

Icon

- - + + [![Language](https://img.shields.io/badge/Swift-3%20%26%204-orange.svg)]() [![GitHub license](https://img.shields.io/cocoapods/l/PMAlertController.svg)](https://github.com/pmusolino/PMAlertController/blob/master/LICENSE) [![Pod version](https://img.shields.io/cocoapods/v/PMAlertController.svg?style=flat)](https://cocoapods.org/pods/PMAlertController) [![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-yellow.svg)](https://github.com/Carthage/Carthage) [![Downloads](https://img.shields.io/cocoapods/dt/PMAlertController.svg)](https://cocoapods.org/pods/PMAlertController) - + PMAlertController is a small library that allows you to substitute Apple's uncustomizable `UIAlertController`, with a beautiful and totally customizable alert that you can use in your iOS app. Enjoy! @@ -32,7 +32,7 @@ PMAlertController is a small library that allows you to substitute Apple's uncus - [x] Carthage - [x] Animation with UIKit Dynamics - [x] Objective-C compatibility -- [x] Swift 2.3, Swift 3 and Swift 4 support +- [x] Swift 2.3, Swift 3, Swift 4, Swift 4.2 support - [ ] Swift Package Manager @@ -112,15 +112,15 @@ let alertVC = PMAlertController(title: "A Title", description: "My Description", alertVC.addAction(PMAlertAction(title: "Cancel", style: .cancel, action: { () -> Void in print("Capture action Cancel") })) - + alertVC.addAction(PMAlertAction(title: "OK", style: .default, action: { () in print("Capture action OK") })) - + alertVC.addTextField { (textField) in textField?.placeholder = "Location..." } - + self.present(alertVC, animated: true, completion: nil) ``` From 6556c1d2e0dd04d6500e471a2b4efc616d6755f1 Mon Sep 17 00:00:00 2001 From: Oleg Gorbatchev Date: Fri, 21 Sep 2018 10:30:18 +0200 Subject: [PATCH 2/2] Updated plist and swift-version --- .swift-version | 2 +- PMAlertController/Info.plist | 2 +- PMAlertControllerSample/Info.plist | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.swift-version b/.swift-version index 389f774..bf77d54 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 \ No newline at end of file +4.2 diff --git a/PMAlertController/Info.plist b/PMAlertController/Info.plist index c37e387..dc51e0c 100644 --- a/PMAlertController/Info.plist +++ b/PMAlertController/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 3.4.0 + 3.5.0 CFBundleSignature ???? CFBundleVersion diff --git a/PMAlertControllerSample/Info.plist b/PMAlertControllerSample/Info.plist index 05dd4c6..0266b01 100644 --- a/PMAlertControllerSample/Info.plist +++ b/PMAlertControllerSample/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0.2 + 1.0.3 CFBundleSignature ???? CFBundleVersion