Browse Source

set appearance

marinofaggiana 5 years ago
parent
commit
e3597b508a
2 changed files with 21 additions and 0 deletions
  1. 7 0
      iOSClient/AppDelegate.m
  2. 14 0
      iOSClient/Utility/NCUtility.swift

+ 7 - 0
iOSClient/AppDelegate.m

@@ -990,6 +990,13 @@
     [[NCMainCommon sharedInstance] createImagesThemingColor];
     
     [[NSNotificationCenter defaultCenter] postNotificationOnMainThreadName:k_notificationCenter_changeTheming object:nil];
+    
+    // Appearance
+    UINavigationBar.appearance.tintColor = NCBrandColor.sharedInstance.brandText;
+    UINavigationBar.appearance.barTintColor = NCBrandColor.sharedInstance.brand;
+    [UINavigationBar.appearance setBackgroundImage:[[NCUtility sharedInstance] fromColorWithColor:NCBrandColor.sharedInstance.brand] forBarMetrics: UIBarMetricsDefault];
+    UINavigationBar.appearance.titleTextAttributes = @{NSForegroundColorAttributeName : NCBrandColor.sharedInstance.brandText};
+    UINavigationBar.appearance.translucent = false;
 }
 
 - (void)changeTheming:(UIViewController *)viewController tableView:(UITableView *)tableView collectionView:(UICollectionView *)collectionView form:(BOOL)form

+ 14 - 0
iOSClient/Utility/NCUtility.swift

@@ -519,5 +519,19 @@ class NCUtility: NSObject {
     @objc func isQuickLookDisplayable(metadata: tableMetadata) -> Bool {
         return true
     }
+    
+    @objc func fromColor(color: UIColor) -> UIImage {
+        
+        let rect = CGRect(x: 0, y: 0, width: 1, height: 1)
+        
+        UIGraphicsBeginImageContext(rect.size)
+        let context: CGContext? = UIGraphicsGetCurrentContext()
+        context?.setFillColor(color.cgColor)
+        context?.fill(rect)
+        let image: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
+        UIGraphicsEndImageContext()
+        
+        return image ?? UIImage()
+    }
 }