Sfoglia il codice sorgente

综合(iOS) - 适配iOS 15的导航栏

dinglingui 1 anno fa
parent
commit
aebb2cb704

+ 11 - 1
ComPDFKit_Tools/ComPDFKit_Tools/Common/Controls/PDFNavigationController/CNavigationController.m

@@ -12,6 +12,8 @@
 
 #import "CNavigationController.h"
 
+#import "CPDFColorUtils.h"
+
 @interface CNavigationController ()
 
 @end
@@ -20,7 +22,15 @@
 
 - (void)viewDidLoad {
     [super viewDidLoad];
-    // Do any additional setup after loading the view.
+    
+    if (@available(iOS 15.0, *)) {
+        UINavigationBarAppearance *navgationBarApp = [[UINavigationBarAppearance alloc] init];
+        navgationBarApp.backgroundColor = [CPDFColorUtils CNavBackgroundColor];
+        [UINavigationBar appearance].scrollEdgeAppearance = navgationBarApp;
+        [UINavigationBar appearance].standardAppearance = navgationBarApp;
+        
+        [UITableView appearance].sectionHeaderTopPadding = 0;
+    }    // Do any additional setup after loading the view.
 }
 
 /*

+ 2 - 0
ComPDFKit_Tools/ComPDFKit_Tools/Common/Utils/CPDFColorUtils.h

@@ -42,6 +42,8 @@ NS_ASSUME_NONNULL_BEGIN
 
 + (UIColor *)CPDFKeyboardToolbarColor;
 
++ (UIColor *)CNavBackgroundColor;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 9 - 0
ComPDFKit_Tools/ComPDFKit_Tools/Common/Utils/CPDFColorUtils.m

@@ -118,4 +118,13 @@
     }
 }
 
++ (UIColor *)CNavBackgroundColor
+{
+    if (@available(iOS 13.0, *)) {
+        return [UIColor colorNamed:@"KMNavBackgroundColor"];
+    } else {
+        return [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0];
+    }
+}
+
 @end

+ 38 - 0
ComPDFKit_Tools/ComPDFKit_Tools/Common/Utils/UtilsColor.xcassets/CNavBackgroundColor.colorset/Contents.json

@@ -0,0 +1,38 @@
+{
+  "colors" : [
+    {
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "1.000",
+          "blue" : "1.000",
+          "green" : "1.000",
+          "red" : "1.000"
+        }
+      },
+      "idiom" : "universal"
+    },
+    {
+      "appearances" : [
+        {
+          "appearance" : "luminosity",
+          "value" : "dark"
+        }
+      ],
+      "color" : {
+        "color-space" : "srgb",
+        "components" : {
+          "alpha" : "0.800",
+          "blue" : "0.086",
+          "green" : "0.086",
+          "red" : "0.086"
+        }
+      },
+      "idiom" : "universal"
+    }
+  ],
+  "info" : {
+    "author" : "xcode",
+    "version" : 1
+  }
+}