Browse Source

PDFTools(iOS) - 颜色加载问题

dinglingui 1 year ago
parent
commit
23b901caa0

+ 10 - 8
compdfkit-tools/compdfkit-tools.xcodeproj/project.pbxproj

@@ -7,8 +7,6 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
-		C949FEE329EE70D000C30A8D /* UIColor+Utils.h in Headers */ = {isa = PBXBuildFile; fileRef = C949FEE129EE70D000C30A8D /* UIColor+Utils.h */; settings = {ATTRIBUTES = (Public, ); }; };
-		C949FEE429EE70D000C30A8D /* UIColor+Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = C949FEE229EE70D000C30A8D /* UIColor+Utils.m */; };
 		C9AF182629EE8AB600EC4979 /* UtilsColor.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C9AF182529EE8AB600EC4979 /* UtilsColor.xcassets */; };
 		C9B0CE1829E6486700524B7F /* ComPDFKit.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = F313657129E4367A00EE6BBB /* ComPDFKit.xcframework */; };
 		F32DA16229ED904300E19ECA /* CPDFOutlineModel.h in Headers */ = {isa = PBXBuildFile; fileRef = F32DA12229ED904300E19ECA /* CPDFOutlineModel.h */; };
@@ -61,12 +59,12 @@
 		F382637129EFD11D003F1DFD /* CPDFListView+Viewer.h in Headers */ = {isa = PBXBuildFile; fileRef = F382636F29EFD11D003F1DFD /* CPDFListView+Viewer.h */; };
 		F382637229EFD11D003F1DFD /* CPDFListView+Viewer.m in Sources */ = {isa = PBXBuildFile; fileRef = F382637029EFD11D003F1DFD /* CPDFListView+Viewer.m */; };
 		F3877E1629E6764E00037D92 /* CPDFDisplayViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = F3877E1429E6764E00037D92 /* CPDFDisplayViewController.h */; };
+		F38F60C629EFF0C2008098F8 /* CPDFColorUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = F38F60C429EFF0C1008098F8 /* CPDFColorUtils.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		F38F60C729EFF0C2008098F8 /* CPDFColorUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = F38F60C529EFF0C1008098F8 /* CPDFColorUtils.m */; };
 		F3E8495929E69712007BE967 /* DisplayImage.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F3E8495829E69712007BE967 /* DisplayImage.xcassets */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
-		C949FEE129EE70D000C30A8D /* UIColor+Utils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIColor+Utils.h"; sourceTree = "<group>"; };
-		C949FEE229EE70D000C30A8D /* UIColor+Utils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIColor+Utils.m"; sourceTree = "<group>"; };
 		C9AF182529EE8AB600EC4979 /* UtilsColor.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = UtilsColor.xcassets; sourceTree = "<group>"; };
 		F313657129E4367A00EE6BBB /* ComPDFKit.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = ComPDFKit.xcframework; path = ../Lib/ComPDFKit.xcframework; sourceTree = "<group>"; };
 		F32DA12229ED904300E19ECA /* CPDFOutlineModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CPDFOutlineModel.h; sourceTree = "<group>"; };
@@ -121,6 +119,8 @@
 		F382636F29EFD11D003F1DFD /* CPDFListView+Viewer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CPDFListView+Viewer.h"; sourceTree = "<group>"; };
 		F382637029EFD11D003F1DFD /* CPDFListView+Viewer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "CPDFListView+Viewer.m"; sourceTree = "<group>"; };
 		F3877E1429E6764E00037D92 /* CPDFDisplayViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFDisplayViewController.h; sourceTree = "<group>"; };
+		F38F60C429EFF0C1008098F8 /* CPDFColorUtils.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFColorUtils.h; sourceTree = "<group>"; };
+		F38F60C529EFF0C1008098F8 /* CPDFColorUtils.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFColorUtils.m; sourceTree = "<group>"; };
 		F3E8495829E69712007BE967 /* DisplayImage.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = DisplayImage.xcassets; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
@@ -140,8 +140,8 @@
 			isa = PBXGroup;
 			children = (
 				C9AF182529EE8AB600EC4979 /* UtilsColor.xcassets */,
-				C949FEE129EE70D000C30A8D /* UIColor+Utils.h */,
-				C949FEE229EE70D000C30A8D /* UIColor+Utils.m */,
+				F38F60C429EFF0C1008098F8 /* CPDFColorUtils.h */,
+				F38F60C529EFF0C1008098F8 /* CPDFColorUtils.m */,
 			);
 			path = Utils;
 			sourceTree = "<group>";
@@ -439,9 +439,9 @@
 				F32DA17029ED904300E19ECA /* CPDFThumbnailViewCell.h in Headers */,
 				F32DA17929ED904300E19ECA /* CPDFDisplayViewController.h in Headers */,
 				F32DA16C29ED904300E19ECA /* CPDFSearchResultsViewController.h in Headers */,
-				C949FEE329EE70D000C30A8D /* UIColor+Utils.h in Headers */,
 				F382636829EFD0D9003F1DFD /* CPDFPageIndicatorView.h in Headers */,
 				F32DA16529ED904300E19ECA /* CPDFOutlineViewController.h in Headers */,
+				F38F60C629EFF0C2008098F8 /* CPDFColorUtils.h in Headers */,
 				F32DA17829ED904300E19ECA /* CPDFDisplayTableViewCell.h in Headers */,
 				F32DA17129ED904300E19ECA /* CPDFThumbnailViewController.h in Headers */,
 				F32DA16229ED904300E19ECA /* CPDFOutlineModel.h in Headers */,
@@ -526,7 +526,6 @@
 			buildActionMask = 2147483647;
 			files = (
 				F32DA17B29ED904300E19ECA /* CPDFDisplayViewController.m in Sources */,
-				C949FEE429EE70D000C30A8D /* UIColor+Utils.m in Sources */,
 				F32DA17F29ED904300E19ECA /* CNavigationController.m in Sources */,
 				F382636D29EFD0D9003F1DFD /* CPDFListView.m in Sources */,
 				F32DA17329ED904300E19ECA /* CPDFThumbnailViewController.m in Sources */,
@@ -537,6 +536,7 @@
 				F382636A29EFD0D9003F1DFD /* CPDFSlider.m in Sources */,
 				F32DA16629ED904300E19ECA /* CPDFOutlineModel.m in Sources */,
 				F32DA16729ED904300E19ECA /* CPDFOutlineViewController.m in Sources */,
+				F38F60C729EFF0C2008098F8 /* CPDFColorUtils.m in Sources */,
 				F32DA17A29ED904300E19ECA /* CPDFDisplayTableViewCell.m in Sources */,
 				F32DA17D29ED904300E19ECA /* CPDFBOTAViewController.m in Sources */,
 				F32DA19229ED908800E19ECA /* CPDFMoreListViewController.m in Sources */,
@@ -680,6 +680,7 @@
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_CURRENT_VERSION = 1;
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
+				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				FRAMEWORK_SEARCH_PATHS = "";
 				GENERATE_INFOPLIST_FILE = YES;
 				HEADER_SEARCH_PATHS = "";
@@ -712,6 +713,7 @@
 				DYLIB_COMPATIBILITY_VERSION = 1;
 				DYLIB_CURRENT_VERSION = 1;
 				DYLIB_INSTALL_NAME_BASE = "@rpath";
+				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				FRAMEWORK_SEARCH_PATHS = "";
 				GENERATE_INFOPLIST_FILE = YES;
 				HEADER_SEARCH_PATHS = "";

+ 3 - 3
compdfkit-tools/compdfkit-tools/Common/Controls/BOTA/CPDFBOTAViewController.m

@@ -13,7 +13,7 @@
 #import "CPDFBOTAViewController.h"
 #import "CPDFThumbnailViewController.h"
 #import "CPDFOutlineViewController.h"
-#import "UIColor+Utils.h"
+#import "CPDFColorUtils.h"
 
 #import <ComPDFKit/ComPDFKit.h>
 
@@ -84,8 +84,8 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     self.title = NSLocalizedString(@"BOTA", nil);
-    
-    self.view.backgroundColor = [UIColor CPDFViewControllerBackgroundColor];
+
+    self.view.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
     
     self.segmentedControl.selectedSegmentIndex = 0;
     [self.view addSubview:self.segmentedControl];

+ 4 - 3
compdfkit-tools/compdfkit-tools/Common/Utils/UIColor+Utils.h

@@ -1,5 +1,5 @@
 //
-//  UIColor+Utils.h
+//  CPDFColorUtils.h
 //  compdfkit-tools
 //
 //  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
@@ -12,11 +12,12 @@
 
 #import <UIKit/UIKit.h>
 
-@interface UIColor (Utils)
+NS_ASSUME_NONNULL_BEGIN
 
-+ (UIColor *)lightColor:(UIColor *)lightColor darkColor:(UIColor *)darkColor;
+@interface CPDFColorUtils : NSObject
 
 + (UIColor *)CPDFViewControllerBackgroundColor;
 
 @end
 
+NS_ASSUME_NONNULL_END

+ 4 - 20
compdfkit-tools/compdfkit-tools/Common/Utils/UIColor+Utils.m

@@ -1,5 +1,5 @@
 //
-//  UIColor+Utils.m
+//  CPDFColorUtils.m
 //  compdfkit-tools
 //
 //  Copyright © 2014-2023 PDF Technologies, Inc. All Rights Reserved.
@@ -10,31 +10,15 @@
 //  This notice may not be removed from this file.
 //
 
-#import "UIColor+Utils.h"
+#import "CPDFColorUtils.h"
 
-@implementation UIColor (Utils)
-
-+ (UIColor *)lightColor:(UIColor *)lightColor darkColor:(UIColor *)darkColor
-{
-    if (@available(iOS 13.0, *)) {
-         return [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull trait) {
-            if (trait.userInterfaceStyle == UIUserInterfaceStyleDark) {
-                return darkColor;
-            } else {
-                return lightColor;
-            }
-        }];
-    } else {
-        return lightColor;
-    }
-}
+@implementation CPDFColorUtils
 
 + (UIColor *)CPDFViewControllerBackgroundColor {
     if (@available(iOS 13.0, *)) {
-        return [UIColor colorNamed:@"CPDFViewControllerBackgroundColor" inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:nil];
+        return [UIColor colorNamed:@"CPDFViewControllerBackgroundColor" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
     } else {
         return [UIColor whiteColor];
     }
 }
-
 @end

+ 3 - 3
compdfkit-tools/compdfkit-tools/Common/Views/PDFView/PDFListView/CPDFListView.m

@@ -14,7 +14,7 @@
 
 #import "CPDFListView+Viewer.h"
 
-#import "UIColor+Utils.h"
+#import "CPDFColorUtils.h"
 
 #import "CPDFSlider.h"
 #import "CPDFPageIndicatorView.h"
@@ -33,7 +33,7 @@
 
 - (instancetype)initWithFrame:(CGRect)frame {
     if (self = [super initWithFrame:frame]) {
-        self.backgroundColor = [UIColor CPDFViewControllerBackgroundColor];
+        self.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
         
         [self commomInit];
         
@@ -46,7 +46,7 @@
 - (id)initWithCoder:(NSCoder *)decoder {
     self = [super initWithCoder:decoder];
     if (self) {
-        self.backgroundColor = [UIColor CPDFViewControllerBackgroundColor];
+        self.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
 
         [self commomInit];
 

+ 2 - 2
compdfkit-tools/compdfkit-tools/Common/Views/PDFView/PDFPageIndicatorView/CPDFPageIndicatorView.m

@@ -11,7 +11,7 @@
 //
 
 #import "CPDFPageIndicatorView.h"
-#import "UIColor+Utils.h"
+#import "CPDFColorUtils.h"
 
 @interface CPDFPageIndicatorView()
 
@@ -37,7 +37,7 @@
         [self.pageNumButton setTitleColor:[UIColor systemTealColor] forState:UIControlStateNormal];
         self.indicatorCornerRadius = 5;
         
-        self.backgroundColor = [UIColor CPDFViewControllerBackgroundColor];
+        self.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
     }
     return self;
 }

+ 2 - 2
compdfkit-tools/compdfkit-tools/Viewer/PDFSearch/CSearchToolbar.m

@@ -13,7 +13,7 @@
 #import "CSearchToolbar.h"
 
 #import <ComPDFKit/ComPDFKit.h>
-#import "UIColor+Utils.h"
+#import "CPDFColorUtils.h"
 
 #import "CPDFSearchResultsViewController.h"
 #import "CNavigationController.h"
@@ -55,7 +55,7 @@
         
         [self commonInit];
         
-        self.backgroundColor = [UIColor CPDFViewControllerBackgroundColor];
+        self.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
     }
     return self;
 }

+ 1 - 1
compdfkit-tools/compdfkit-tools/compdfkit_tools.h

@@ -12,7 +12,7 @@
 
 #import <Foundation/Foundation.h>
 
-#import <compdfkit_tools/UIColor+Utils.h>
+#import <compdfkit_tools/CPDFColorUtils.h>
 
 // Navigtion
 #import <compdfkit_tools/CNavigationController.h>

+ 2 - 0
viewer-ctrl-demo/viewer-ctrl-demo.xcodeproj/project.pbxproj

@@ -362,6 +362,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 4GGQPGRTSV;
+				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GENERATE_INFOPLIST_FILE = YES;
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "viewer-ctrl-demo/Info.plist";
@@ -391,6 +392,7 @@
 				CODE_SIGN_STYLE = Automatic;
 				CURRENT_PROJECT_VERSION = 1;
 				DEVELOPMENT_TEAM = 4GGQPGRTSV;
+				"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = arm64;
 				GENERATE_INFOPLIST_FILE = YES;
 				HEADER_SEARCH_PATHS = "";
 				INFOPLIST_FILE = "viewer-ctrl-demo/Info.plist";

+ 1 - 1
viewer-ctrl-demo/viewer-ctrl-demo/CPDFViewController.m

@@ -45,7 +45,7 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     
-    self.view.backgroundColor = [UIColor CPDFViewControllerBackgroundColor];
+    self.view.backgroundColor = [CPDFColorUtils CPDFViewControllerBackgroundColor];
     
     self.pdfListView = [[CPDFListView alloc] initWithFrame:self.view.bounds];
     self.pdfListView.performDelegate = self;