Browse Source

PDFAnnotation(iOS) - 签名注释预编辑无法改变颜色问题和横屏重叠问题

yangliuhua 1 year ago
parent
commit
f1a6f08b15

+ 15 - 3
ComPDFKit_Tools/ComPDFKit_Tools/Annotations/PDFAnnotationProperties/PDFSignature/CPDFSignatureEditViewController.m

@@ -477,6 +477,7 @@
             self.clearButton.center = CGPointMake(self.clearButton.center.x, self.clearButton.center.y-150);
             self.textField.center = CGPointMake(self.textField.center.x, self.textField.center.y-150);
         } completion:nil];
+        self.colorSelectView.hidden = YES;
     }
 }
 
@@ -490,6 +491,7 @@
             self.clearButton.center = CGPointMake(self.clearButton.center.x, self.clearButton.center.y+150);
             self.textField.center = CGPointMake(self.textField.center.x, self.textField.center.y+150);
         } completion:nil];
+        self.colorSelectView.hidden = NO;
     }
 }
 
@@ -590,7 +592,11 @@
 #pragma mark - CPDFColorSelectViewDelegate
 
 - (void)selectColorView:(CPDFColorSelectView *)select color:(UIColor *)color {
-    self.textField.textColor = color;
+    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.textField.text];
+    [attributedString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, attributedString.length)];
+
+    self.textField.attributedText = attributedString;
+    
     self.signatureDrawTextView.color = color;
     [self.signatureDrawTextView setNeedsDisplay];
 }
@@ -620,7 +626,10 @@
 
 - (void)pickerView:(CPDFColorPickerView *)colorPickerView color:(UIColor *)color {
     self.signatureDrawTextView.color = color;
-    self.textField.textColor = color;
+    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.textField.text];
+    [attributedString addAttribute:NSForegroundColorAttributeName value:color range:NSMakeRange(0, attributedString.length)];
+
+    self.textField.attributedText = attributedString;
     [self.signatureDrawImageView setNeedsDisplay];
     
     [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
@@ -630,7 +639,10 @@
 
 - (void)colorPickerViewControllerDidFinish:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0)) {
     self.signatureDrawTextView.color = viewController.selectedColor;
-    self.textField.textColor = self.signatureDrawTextView.color;
+    NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:self.textField.text];
+    [attributedString addAttribute:NSForegroundColorAttributeName value:self.signatureDrawTextView.color range:NSMakeRange(0, attributedString.length)];
+
+    self.textField.attributedText = attributedString;
     [self.signatureDrawTextView setNeedsDisplay];
 }