Dark tabs for Zenith! Mirror of https://github.com/mac-user669/ZenithDark
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

47 linhas
1.6KB

  1. // We make an interface to let Theos know that ZNGrabberAccessoryView is of type UIImageView;
  2. @interface ZNGrabberAccessoryView : UIImageView
  3. @end
  4. BOOL kDarkModeEnabled;
  5. /*
  6. Colorize Zenith's Grabber view with ease!
  7. Copyright 2020 J.K. Hayslip (@iKilledAppl3) & ToxicAppl3 INSDC/iKilledAppl3 LLC.
  8. All code was written for learning purposes and credit must be given to the original author.
  9. */
  10. // We then import UIKit so we can override the color property without this Theos doesn't have a clue what those properties are.
  11. @import UIKit;
  12. //We then hook the class in this case Zenith's grabber view is called “ZNGrabberAccessoryView”
  13. %hook ZNGrabberAccessoryView
  14. // the method we then modify is this method that is called from UIImageView to set the backgroundColor of the image view.
  15. // Since the grabber view is of type UIImageView we can modify this method :)
  16. -(void)setBackgroundColor:(UIColor *)backgroundColor {
  17. //call the original function then pass our custom argument to the backgroundColor argument as shown below.
  18. kDarkModeEnabled = ([UITraitCollection currentTraitCollection].userInterfaceStyle == UIUserInterfaceStyleDark);
  19. if (kDarkModeEnabled) {
  20. %orig([UIColor colorWithWhite:0.0 alpha:0.44]);
  21. }
  22. else {
  23. %orig;
  24. }
  25. }
  26. // we need to make sure we tell theos that we are finished hooking this class not doing so with cause the end of the world :P
  27. %end
  28. // our constructor
  29. %ctor {
  30. // We use this to make sure we load Zenith's dynamic library at runtime so we can modify it with our tweak.
  31. dlopen ("/Library/MobileSubstrate/DynamicLibraries/Zenith.dylib", RTLD_NOW);
  32. }