Skip to content

Commit

Permalink
Merge pull request #71 from gorbat-o/swift4.2
Browse files Browse the repository at this point in the history
Updated for swift4.2 and fix warning (removed force cast)
  • Loading branch information
pmusolino committed Sep 23, 2018
2 parents 409f2d8 + 6556c1d commit a3346d9
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
4.2
4 changes: 2 additions & 2 deletions Library/PMAlertAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
16 changes: 7 additions & 9 deletions Library/PMAlertController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PMAlertController.podspec
Original file line number Diff line number Diff line change
@@ -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!
Expand Down
8 changes: 4 additions & 4 deletions PMAlertController.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand All @@ -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;
};
Expand Down Expand Up @@ -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 = "";
};
Expand All @@ -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 = "";
};
Expand Down
2 changes: 1 addition & 1 deletion PMAlertController/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.4.0</string>
<string>3.5.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion PMAlertControllerSample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<p align="center">
<img src="https://raw.githubusercontent.com/pmusolino/PMAlertController/master/logo_pmalertcontroller.png" alt="Icon"/>
</p>


[![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!

Expand All @@ -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


Expand Down Expand Up @@ -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)

```
Expand Down

0 comments on commit a3346d9

Please sign in to comment.