AppearanceManager.swift 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*****************************************************************************
  2. * AppearanceManager.swift
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2018 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Carola Nitz <nitz.carola # gmail.com>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. import UIKit
  13. @objc(VLCApperanceManager)
  14. class AppearanceManager: NSObject {
  15. @objc class func setupAppearance(theme: PresentationTheme = PresentationTheme.current) {
  16. // Change the keyboard for UISearchBar
  17. UITextField.appearance().keyboardAppearance = theme == PresentationTheme.darkTheme ? .dark : .light
  18. // For the cursor
  19. UITextField.appearance().tintColor = theme.colors.orangeUI
  20. // Don't override the 'Cancel' button color in the search bar with the previous UITextField call. Use the default blue color
  21. let attributes = [NSAttributedStringKey.foregroundColor: UIColor.white]
  22. UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).setTitleTextAttributes(attributes, for: .normal)
  23. UINavigationBar.appearance().barTintColor = theme.colors.orangeUI
  24. UINavigationBar.appearance(whenContainedInInstancesOf: [VLCPlaybackNavigationController.self]).barTintColor = nil
  25. UINavigationBar.appearance().tintColor = .white
  26. UINavigationBar.appearance().titleTextAttributes = attributes
  27. if #available(iOS 11.0, *) {
  28. UINavigationBar.appearance().prefersLargeTitles = true
  29. UINavigationBar.appearance(whenContainedInInstancesOf:[VLCPlaybackNavigationController.self]).prefersLargeTitles = false
  30. UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor : UIColor.white]
  31. }
  32. // For the edit selection indicators
  33. UITableView.appearance().tintColor = theme.colors.orangeUI
  34. UISegmentedControl.appearance().tintColor = theme.colors.orangeUI
  35. UISwitch.appearance().onTintColor = theme.colors.orangeUI
  36. UISearchBar.appearance().barTintColor = .white
  37. UITabBar.appearance().tintColor = theme.colors.orangeUI
  38. //customization of MoreViewController
  39. //Since there is no clean way to customize the Morecontroller appearance we're getting the class
  40. if let moreListControllerClass = NSClassFromString("UIMoreListController") as? UIAppearanceContainer.Type {
  41. UITableViewCell.appearance(whenContainedInInstancesOf: [moreListControllerClass.self]).backgroundColor = theme.colors.cellBackgroundA
  42. UITableViewCell.appearance(whenContainedInInstancesOf: [moreListControllerClass.self]).textLabel?.textColor = theme.colors.cellTextColor
  43. UITableView.appearance(whenContainedInInstancesOf: [moreListControllerClass.self]).backgroundColor = theme.colors.background
  44. UITableView.appearance(whenContainedInInstancesOf: [moreListControllerClass.self]).separatorColor = .lightGray
  45. UILabel.appearance(whenContainedInInstancesOf: [moreListControllerClass.self]).textColor = theme.colors.cellTextColor
  46. }
  47. }
  48. }