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

removed some warnings and added support for iOS13 #11

Open
wants to merge 2 commits 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
16 changes: 12 additions & 4 deletions MKToolTip/MKToolTip/MKToolTip.swift
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import UIKit

public extension UIView {

@objc public func showToolTip(identifier: String, title: String? = nil, message: String, button: String? = nil, arrowPosition: MKToolTip.ArrowPosition, preferences: ToolTipPreferences = ToolTipPreferences(), delegate: MKToolTipDelegate? = nil) {
@objc func showToolTip(identifier: String, title: String? = nil, message: String, button: String? = nil, arrowPosition: MKToolTip.ArrowPosition, preferences: ToolTipPreferences = ToolTipPreferences(), delegate: MKToolTipDelegate? = nil) {
let tooltip = MKToolTip(view: self, identifier: identifier, title: title, message: message, button: button, arrowPosition: arrowPosition, preferences: preferences, delegate: delegate)
tooltip.calculateFrame()
tooltip.show()
Expand All @@ -42,12 +42,11 @@ public extension UIView {

public extension UIBarItem {

@objc public func showToolTip(identifier: String, title: String? = nil, message: String, button: String? = nil, arrowPosition: MKToolTip.ArrowPosition, preferences: ToolTipPreferences = ToolTipPreferences(), delegate: MKToolTipDelegate? = nil) {
@objc func showToolTip(identifier: String, title: String? = nil, message: String, button: String? = nil, arrowPosition: MKToolTip.ArrowPosition, preferences: ToolTipPreferences = ToolTipPreferences(), delegate: MKToolTipDelegate? = nil) {
if let view = self.view {
view.showToolTip(identifier: identifier, title: title, message: message, button: button, arrowPosition: arrowPosition, preferences: preferences, delegate: delegate)
}
}

}

// MARK: Preferences
Expand Down Expand Up @@ -351,7 +350,16 @@ open class MKToolTip: UIView {
}

private func createWindow(with viewController: UIViewController) {
self.containerWindow = UIWindow(frame: UIScreen.main.bounds)
if #available(iOS 13.0, *) {
let windowScene = UIApplication.shared.connectedScenes.filter {$0.activationState == .foregroundActive}.first
if let windowScene = windowScene as? UIWindowScene {
self.containerWindow = UIWindow(windowScene: windowScene)
}
} else {
// Fallback on earlier versions
self.containerWindow = UIWindow(frame: UIScreen.main.bounds)
}

self.containerWindow!.rootViewController = viewController
self.containerWindow!.windowLevel = UIWindow.Level.alert + 1;
self.containerWindow!.makeKeyAndVisible()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Installation
To integrate MKToolTip into your Xcode project using CocoaPods, specify it in your `Podfile`:

```ruby
pod 'MKToolTip'
pod 'MKToolTip', :git => "https://github.com/mrugeshtank/MKToolTip.git"
```

Then, run the following command:
Expand Down