Ver Fonte

【视图】黑暗模式兼容

lizhe há 1 ano atrás
pai
commit
7faec5cc4f

+ 49 - 2
PDF Office/PDF Master/Class/PDFWindowController/Side/RightSide/AnnotationProperty/KMAnnotationPropertiesViewController.m

@@ -62,11 +62,57 @@
 
 
 #pragma mark - View Methods
 #pragma mark - View Methods
 
 
+//func addNotification() {
+//    NotificationCenter.default.addObserver(self, selector: #selector(changeEffectiveAppearance), name: NSNotification.Name(rawValue: "kEffectiveAppearance"), object: nil)
+//}
+//
+//func removeNotification() {
+//    NotificationCenter.default.removeObserver(self)
+//    DistributedNotificationCenter.default().removeObserver(self)
+//}
+//
+//@objc func changeEffectiveAppearance() {
+//    let isDarkModel = KMAdvertisementConfig.isDarkModel()
+//    if isDarkModel {
+//        self.appearance = NSAppearance(named: .darkAqua)
+//    } else {
+//        self.appearance = NSAppearance(named: .aqua)
+//    }
+//    self.updateUI()
+//}
+
+- (void)dealloc {
+    [self removeNotification];
+}
+
+- (void)addNotification {
+    [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(changeEffectiveAppearance) name:@"kEffectiveAppearance" object:nil];
+}
+
+- (void)removeNotification {
+    [NSNotificationCenter.defaultCenter removeObserver:self];
+}
+
+- (void)changeEffectiveAppearance {
+    NSLog(@"changeEffectiveAppearance");
+    BOOL isDarkModel = [KMAdvertisementConfig isDarkModel];
+    if (isDarkModel) {
+        self.view.appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
+        self.view.layer.backgroundColor = [NSColor km_initWithHex:@"#252526" alpha:1].CGColor;
+    } else {
+        self.view.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
+        self.view.layer.backgroundColor = [NSColor km_initWithHex:@"#FAFAFA" alpha:1].CGColor;
+    }
+}
+
 - (void)loadView {
 - (void)loadView {
     [super loadView];
     [super loadView];
     
     
+    [self addNotification];
+    
     self.view.wantsLayer = YES;
     self.view.wantsLayer = YES;
-    self.view.layer.backgroundColor = [NSColor colorWithRed:247.0/255.0 green:248.0/255.0 blue:250.0/255.0 alpha:1].CGColor;
+    self.view.layer.backgroundColor = [KMAppearance viewBackgroundColor].CGColor;
+//    self.view.layer.backgroundColor = [NSColor colorWithRed:247.0/255.0 green:248.0/255.0 blue:250.0/255.0 alpha:1].CGColor;
     self.view.layer.shadowColor = [NSColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.15].CGColor;
     self.view.layer.shadowColor = [NSColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.15].CGColor;
     self.view.layer.shadowOffset = NSMakeSize(0, 0);
     self.view.layer.shadowOffset = NSMakeSize(0, 0);
     self.view.layer.shadowRadius = 4;
     self.view.layer.shadowRadius = 4;
@@ -83,7 +129,8 @@
     self.subTitleLabel.textColor = [NSColor grayColor];
     self.subTitleLabel.textColor = [NSColor grayColor];
     
     
     self.titleLabel.font = [NSFont SFProTextSemiboldFont:14.0];
     self.titleLabel.font = [NSFont SFProTextSemiboldFont:14.0];
-    self.titleLabel.textColor = [NSColor colorWithRed:0.145 green:0.149 blue:0.161 alpha:1];
+    self.titleLabel.textColor = [KMAppearance KMColor_Layout_H0];
+//    [NSColor colorWithRed:0.145 green:0.149 blue:0.161 alpha:1];
     
     
     self.buttonView.hidden = YES;
     self.buttonView.hidden = YES;
     self.formGeneralButton.wantsLayer = YES;
     self.formGeneralButton.wantsLayer = YES;