Last active
June 10, 2017 10:40
-
-
Save KalpeshTalkar/e7769e8875e408806d41cf2eae2ebdf8 to your computer and use it in GitHub Desktop.
The class enables the UIDebuggingInformationOverlay (which is a private UIWindow subclass). This helps developers and designers debug the app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Copyright © 2017 Kalpesh Talkar. All rights reserved. | |
// | |
// Licensed under the Apache License, Version 2.0 (the "License"); | |
// you may not use this file except in compliance with the License. | |
// You may obtain a copy of the License at | |
// | |
// http://www.apache.org/licenses/LICENSE-2.0 | |
// | |
// Unless required by applicable law or agreed to in writing, software | |
// distributed under the License is distributed on an "AS IS" BASIS, | |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
// See the License for the specific language governing permissions and | |
// limitations under the License. | |
// | |
// For support: https://gist.github.com/KalpeshTalkar/e7769e8875e408806d41cf2eae2ebdf8 | |
// | |
import UIKit | |
/// The class enables the UIDebuggingInformationOverlay (which is a private UIWindow subclass) | |
/// This helps developers and designers debug the app. | |
class KDebugInfoOverlay { | |
/// UIDebuggingInformationOverlay private class | |
private static var overlayClass: UIWindow.Type? | |
/// Configure and show UIDebuggingInformationOverlay | |
public static func configureAndShowDebugInfoOverlay() { | |
configureDebugInfoOverlay() | |
showDebugInfoOverlay() | |
} | |
/// Configure UIDebuggingInformationOverlay | |
public static func configureDebugInfoOverlay() { | |
overlayClass = NSClassFromString("UIDebuggingInformationOverlay") as? UIWindow.Type | |
_ = overlayClass?.perform(NSSelectorFromString("prepareDebuggingOverlay")) | |
} | |
/// Show UIDebuggingInformationOverlay | |
public static func showDebugInfoOverlay() { | |
// Configure the UIDebuggingInformationOverlay if the class is nil | |
if (nil == overlayClass) { | |
configureDebugInfoOverlay() | |
} | |
// Show UIDebuggingInformationOverlay | |
let overlay = overlayClass?.perform(NSSelectorFromString("overlay")).takeUnretainedValue() as? UIWindow | |
_ = overlay?.perform(NSSelectorFromString("toggleVisibility")) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment