Last active
June 16, 2017 21:14
-
-
Save coryalder/6d1596606f36ac994193 to your computer and use it in GitHub Desktop.
This file contains 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
class Dummy: NSObject { | |
@objc func barStyle() -> UIStatusBarStyle { | |
return .LightContent | |
} | |
func swizzle() { | |
guard let safariClass = NSClassFromString("SFSafariViewController") else { | |
print("can't swizzle, iOS 8") | |
return | |
} | |
let replacementMethod: Method = class_getInstanceMethod(object_getClass(self), "barStyle") | |
let swizzledMethod = class_getInstanceMethod(safariClass, "preferredStatusBarStyle") | |
method_exchangeImplementations(replacementMethod, swizzledMethod) | |
} | |
} | |
// Elsewhere (i.e. applicationDidFinishLaunching) I call Dummy().swizzle() to run this code. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works around not being able to change SFSafariViewController's status bar color on an app that is deploying to iOS 9.