Last active
April 25, 2018 08:17
-
-
Save aakhedr/a485e008ee2202ae741bb5cfddb77674 to your computer and use it in GitHub Desktop.
Appearance Proxies
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
func appearances() { | |
let windows = UIApplication.shared.windows | |
for window in windows { | |
for view in window.subviews { | |
view.removeFromSuperview() | |
window.addSubview(view) | |
} | |
} | |
setupProxies() | |
} | |
func setupProxies() { | |
/// 1. Navigation Bars | |
UINavigationBar.appearance().titleTextAttributes = [ | |
NSAttributedStringKey.font: Fonts.sharedFonts.navBarTitleFont | |
] | |
if #available(iOS 11.0, *) { | |
UINavigationBar.appearance().largeTitleTextAttributes = [ | |
NSAttributedStringKey.font : Fonts.sharedFonts.navBarLargeTitleFont | |
] | |
} | |
/// 2. Search Bars | |
// A. Search Bar Text Field | |
(UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self])).defaultTextAttributes = [ | |
NSAttributedStringKey.font.rawValue : Fonts.sharedFonts.segmentedControlFont | |
] as [String : Any] | |
// B. Search Bar Scope Buttons | |
UISearchBar.appearance().setScopeBarButtonTitleTextAttributes([ | |
NSAttributedStringKey.font.rawValue : Fonts.sharedFonts.segmentedControlFont | |
] | |
, for: .normal) | |
/// 3. Bar Buttons Items | |
UIBarButtonItem.appearance().setTitleTextAttributes([ | |
NSAttributedStringKey.font: Fonts.sharedFonts.navBarTitleFont | |
] | |
, for: .normal) | |
/// 4. Segmented Controls | |
UISegmentedControl.appearance().setTitleTextAttributes([ | |
NSAttributedStringKey.font : Fonts.sharedFonts.segmentedControlFont | |
] | |
, for: .normal) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment