Browse Source

PDFTools(iOS) - annotstyle模式的完善和自适应

yangliuhua 1 year ago
parent
commit
0655233f4d
16 changed files with 728 additions and 113 deletions
  1. 11 25
      compdfkit-tools/compdfkit-tools/Annotation/PDFAnnotationManage/CAnnotationManage.m
  2. 15 10
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFBase/CPDFAnnotationBaseViewController.m
  3. 3 0
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFBase/CPDFAnnotationBaseViewController_Header.h
  4. 1 0
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFNote/CPDFNoteViewController.m
  5. 54 7
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFShape/CPDFShapeCircleViewController.m
  6. 0 15
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CSignatureDrawView.m
  7. 0 1
      compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CSignatureTopBar.m
  8. 11 3
      compdfkit-tools/compdfkit-tools/Common/Model/CAnnotStyle.h
  9. 467 0
      compdfkit-tools/compdfkit-tools/Common/Model/CAnnotStyle.m
  10. 86 10
      compdfkit-tools/compdfkit-tools/Common/Views/PDFAnnotationBar/CPDFAnnotationBar.m
  11. 25 10
      compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFAnnotationSampleView.m
  12. 20 10
      compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFColorSelectView.m
  13. 0 2
      compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFOpacitySliderView.h
  14. 17 9
      compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFOpacitySliderView.m
  15. 17 10
      compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFThicknessSliderView.m
  16. 1 1
      compdfkit-tools/compdfkit-tools/Edit/CPDFEditCell/CPDFTextPropertyCell.m

+ 11 - 25
compdfkit-tools/compdfkit-tools/Annotation/PDFAnnotationManage/CAnnotationManage.m

@@ -48,24 +48,14 @@
     } else if ([self.annotation isKindOfClass:[CPDFCircleAnnotation class]]) {
         self.annotStyle.annotMode = CPDFViewAnnotationModeCircle;
         self.annotStyle.color = self.annotation.color;
+        self.annotStyle.fillColor = ((CPDFCircleAnnotation *)self.annotation).interiorColor;
+        self.annotStyle.opacity = self.annotation.opacity;
+        self.annotation.borderWidth = self.annotation.borderWidth;
     }
 }
 
 - (void)setAnnotStyleFromMode:(NSInteger)annotationMode {
-    self.annotStyle = [[CAnnotStyle alloc] init];
-    self.annotStyle.annotMode = annotationMode;
-    self.annotStyle.isSelectAnnot = NO;
-    switch (annotationMode) {
-        case CPDFViewAnnotationModeNote:
-        {
-            self.annotation = [[CPDFTextAnnotation alloc] init];
-            self.annotStyle.color = self.annotation.color;
-        }
-            break;
-            
-        default:
-            break;
-    }
+    self.annotStyle = [[CAnnotStyle alloc] initWithAnnotionMode:annotationMode isSelectAnnot:NO];
 }
 
 - (void)refreshAnnotation:(CAnnotStyle *)annotStyle {
@@ -78,7 +68,12 @@
             break;
         case CPDFViewAnnotationModeCircle:
         {
-            self.pdfListView.activeAnnotations.firstObject.color = self.annotStyle.fillColor;
+            CPDFAnnotation *nowAnnotation = self.pdfListView.activeAnnotations.firstObject;
+            nowAnnotation.color = self.annotStyle.color;
+            nowAnnotation.borderWidth = self.annotStyle.borderWidth;
+            nowAnnotation.opacity = self.annotStyle.opacity;
+            ((CPDFCircleAnnotation *)nowAnnotation).interiorColor = self.annotStyle.fillColor;
+            ((CPDFCircleAnnotation *)nowAnnotation).interiorOpacity = self.annotStyle.opacity;
             [self.pdfListView setNeedsDisplayForPage:self.pdfListView.activeAnnotations.firstObject.page];
         }
         default:
@@ -87,16 +82,7 @@
 }
 
 - (void)resetAnnotation:(CAnnotStyle *)annotStyle {
-    switch (annotStyle.annotMode) {
-        case CPDFViewAnnotationModeNote:
-        {
-            
-        }
-            break;
-            
-        default:
-            break;
-    }
+    
 }
 
 - (void)setAnnotStyleFromAnnotation:(CPDFAnnotation *)annotation {

+ 15 - 10
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFBase/CPDFAnnotationBaseViewController.m

@@ -49,8 +49,6 @@
     self.sampleView.backgroundColor = [UIColor whiteColor];
     self.sampleView.layer.borderColor = [UIColor purpleColor].CGColor;
     self.sampleView.layer.borderWidth = 1.0;
-    self.sampleView.fillColor = [UIColor yellowColor];
-    self.sampleView.opcity = 1.0;
     self.sampleView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
     [self.view addSubview:self.sampleView];
     
@@ -67,23 +65,24 @@
     self.view.backgroundColor = [UIColor whiteColor];
     [self updatePreferredContentSizeWithTraitCollection:self.traitCollection];
     [self commomInitTitle];
+    [self commomInitFromAnnotStyle];
 }
 
 - (void)viewWillLayoutSubviews {
     [super viewWillLayoutSubviews];
-    self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, ((self.view.frame.size.height)/8));
-    self.sampleView.frame  = CGRectMake((self.view.frame.size.width - 300)/2, ((self.view.frame.size.height)/8), 300, ((self.view.frame.size.height)/8)*3);
+    self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, ((self.view.frame.size.height)/9));
+    self.sampleView.frame  = CGRectMake((self.view.frame.size.width - 300)/2, ((self.view.frame.size.height)/9), 300, ((self.view.frame.size.height)/9)*3);
     
     if (@available(iOS 11.0, *)) {
         self.colorPicker.frame = CGRectMake(self.view.safeAreaInsets.left, 0, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height);
-        self.colorView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/8)*4,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/8)*2);
-        self.opacitySliderView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/8)*6, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/8)*2);
-        self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60 - self.view.safeAreaInsets.right, 5, 50, ((self.view.frame.size.height)/8));
+        self.colorView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/9)*4,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/9)*2);
+        self.opacitySliderView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/9)*6, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/9)*2);
+        self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60 - self.view.safeAreaInsets.right, 5, 50, ((self.view.frame.size.height)/9));
     } else {
         self.colorPicker.frame = self.view.frame;
-        self.colorView.frame = CGRectMake(0, ((self.view.frame.size.height)/8)*4, self.view.frame.size.width, ((self.view.frame.size.height)/8)*2);
-        self.opacitySliderView.frame = CGRectMake(0, ((self.view.frame.size.height)/8)*6, self.view.frame.size.width, ((self.view.frame.size.height)/8)*2);
-        self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, ((self.view.frame.size.height)/8));
+        self.colorView.frame = CGRectMake(0, ((self.view.frame.size.height)/9)*4, self.view.frame.size.width, ((self.view.frame.size.height)/9)*2);
+        self.opacitySliderView.frame = CGRectMake(0, ((self.view.frame.size.height)/9)*6, self.view.frame.size.width, ((self.view.frame.size.height)/9)*2);
+        self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, ((self.view.frame.size.height)/9));
     }
 }
 
@@ -100,6 +99,12 @@
     self.colorView.colorLabel.text = NSLocalizedString(@"Color:", nil);
 }
 
+- (void)commomInitFromAnnotStyle {
+    self.sampleView.fillColor = self.annotStyle.color;
+    self.sampleView.opcity = self.annotStyle.opacity;
+    self.opacitySliderView.opacitySlider.value = self.annotStyle.opacity;
+}
+
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection {
     self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 270 : 420);
 }

+ 3 - 0
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFBase/CPDFAnnotationBaseViewController_Header.h

@@ -12,6 +12,7 @@
 #import "CPDFColorSelectView.h"
 #import "CPDFOpacitySliderView.h"
 #import "CPDFColorPickerView.h"
+#import "CAnnotStyle.h"
 
 @interface CPDFAnnotationBaseViewController ()
 
@@ -31,6 +32,8 @@
 
 - (void)commomInitTitle;
 
+- (void)commomInitFromAnnotStyle;
+
 - (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection;
 
 @end

+ 1 - 0
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFNote/CPDFNoteViewController.m

@@ -81,6 +81,7 @@
 }
 
 - (void)viewWillLayoutSubviews {
+    [super viewWillLayoutSubviews];
     self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, ((self.view.frame.size.height)/7));
     self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, ((self.view.frame.size.height)/7));
     self.sampleView.frame  = CGRectMake((self.view.frame.size.width - 300)/2, ((self.view.frame.size.height)/7), 300, ((self.view.frame.size.height)/7)*3);

+ 54 - 7
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFShape/CPDFShapeCircleViewController.m

@@ -37,7 +37,6 @@
     // Do any additional setup after loading the view.
     _thicknessView = [[CPDFThicknessSliderView alloc] init];
     _thicknessView.delegate = self;
-    _thicknessView.thicknessSlider.value = 4.0;
     _thicknessView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
     [self.view addSubview:self.thicknessView];
     
@@ -46,12 +45,10 @@
     self.dottedView.thicknessSlider.value = 0.0;
     self.dottedView.thicknessSlider.minimumValue = 0.0;
     self.dottedView.thicknessSlider.maximumValue = 10.0;
-    self.dottedView.startLabel.text = @"0";
-    self.dottedView.endLabel.text = @"10";
     self.dottedView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
     [self.view addSubview:self.dottedView];
     
-    self.fillColorSelectView = [[CPDFColorSelectView alloc] initWithFrame:CGRectMake(0, 280, self.view.frame.size.width, 90)];
+    self.fillColorSelectView = [[CPDFColorSelectView alloc] init];
     self.fillColorSelectView.delegate = self;
     self.fillColorSelectView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
     [self.view addSubview:self.fillColorSelectView];
@@ -59,9 +56,36 @@
 
 - (void)viewWillLayoutSubviews {
     [super viewWillLayoutSubviews];
-    self.opacitySliderView.frame = CGRectMake(10, 370, self.view.frame.size.width - 20, 90);
-    self.thicknessView.frame = CGRectMake(10, 450, self.view.frame.size.width - 20, 90);
-    self.dottedView.frame = CGRectMake(10, 540, self.view.frame.size.width - 20, 90);
+    self.titleLabel.frame = CGRectMake((self.view.frame.size.width - 120)/2, 5, 120, ((self.view.frame.size.height)/15));
+    self.sampleView.frame  = CGRectMake((self.view.frame.size.width - 300)/2, ((self.view.frame.size.height)/15), 300, ((self.view.frame.size.height)/15)*3);
+    
+    if (@available(iOS 11.0, *)) {
+        self.colorPicker.frame = CGRectMake(self.view.safeAreaInsets.left, 0, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, self.view.frame.size.height);
+        self.colorView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/15)*4,self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/15)*2);
+        self.fillColorSelectView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/15)*6, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/15)*2);
+        self.opacitySliderView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/15)*8, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/15)*2);
+        self.thicknessView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/15)*10, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/15)*2);
+        self.dottedView.frame = CGRectMake(self.view.safeAreaInsets.left, ((self.view.frame.size.height)/15)*12, self.view.frame.size.width - self.view.safeAreaInsets.left - self.view.safeAreaInsets.right, ((self.view.frame.size.height)/15)*2);
+        self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60 - self.view.safeAreaInsets.right, 5, 50, ((self.view.frame.size.height)/15));
+    } else {
+        self.colorPicker.frame = self.view.frame;
+        self.colorView.frame = CGRectMake(0, ((self.view.frame.size.height)/15)*4, self.view.frame.size.width, ((self.view.frame.size.height)/15)*2);
+        self.opacitySliderView.frame = CGRectMake(0, ((self.view.frame.size.height)/15)*8, self.view.frame.size.width, ((self.view.frame.size.height)/15)*2);
+        self.fillColorSelectView.frame = CGRectMake(0, ((self.view.frame.size.height)/15)*6, self.view.frame.size.width, ((self.view.frame.size.height)/15)*2);
+        self.thicknessView.frame = CGRectMake(0, ((self.view.frame.size.height)/15)*10, self.view.frame.size.width, ((self.view.frame.size.height)/15)*2);
+        self.dottedView.frame = CGRectMake(0, ((self.view.frame.size.height)/15)*12, self.view.frame.size.width, ((self.view.frame.size.height)/15)*2);
+        self.backBtn.frame = CGRectMake(self.view.frame.size.width - 60, 5, 50, ((self.view.frame.size.height)/15));
+    }
+}
+
+#pragma mark - Protect Mehthods
+
+- (void)commomInitFromAnnotStyle {
+    self.sampleView.fillColor = self.annotStyle.color;
+    self.sampleView.opcity = self.annotStyle.opacity;
+    self.opacitySliderView.opacitySlider.value = self.annotStyle.opacity;
+    self.thicknessView.thicknessSlider.value = self.annotStyle.borderWidth;
+    self.sampleView.fillShapeColor = self.annotStyle.fillColor;
 }
 
 - (void)commomInitTitle {
@@ -80,12 +104,27 @@
     self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 370 : 660);
 }
 
+#pragma mark - CPDFOpacitySliderViewDelegate
+
+- (void)opacitySliderView:(CPDFOpacitySliderView *)opacitySliderView opacity:(CGFloat)opacity {
+    self.sampleView.opcity = opacity;
+    self.annotStyle.opacity = opacity;
+    if (self.delegate && [self.delegate respondsToSelector:@selector(circleViewController:annotStyle:)]) {
+        [self.delegate circleViewController:self annotStyle:self.annotStyle];
+    }
+    [self.sampleView setNeedsDisplay];
+}
+
 #pragma mark - CPDFThicknessSliderViewDelegate
 
 - (void)thicknessSliderView:(CPDFThicknessSliderView *)thicknessSliderView thickness:(CGFloat)thickness {
     if (thicknessSliderView == self.thicknessView) {
         self.sampleView.thickness = thickness;
+        self.annotStyle.borderWidth = thickness;
         [self.sampleView setNeedsDisplay];
+        if (self.delegate && [self.delegate respondsToSelector:@selector(circleViewController:annotStyle:)]) {
+            [self.delegate circleViewController:self annotStyle:self.annotStyle];
+        }
     } else if (thicknessSliderView == self.dottedView) {
         self.sampleView.dotted = thickness;
         [self.sampleView setNeedsDisplay];
@@ -133,10 +172,18 @@
 - (void)pickerView:(CPDFColorPickerView *)colorPickerView color:(UIColor *)color {
     if (colorPickerView == self.colorPicker) {
         self.sampleView.fillColor = color;
+        self.annotStyle.color = color;
         [self.sampleView setNeedsDisplay];
+        if (self.delegate && [self.delegate respondsToSelector:@selector(circleViewController:annotStyle:)]) {
+            [self.delegate circleViewController:self annotStyle:self.annotStyle];
+        }
     } else if (colorPickerView == self.fillColorPicker) {
         self.sampleView.fillShapeColor = color;
+        self.annotStyle.fillColor = color;
         [self.sampleView setNeedsDisplay];
+        if (self.delegate && [self.delegate respondsToSelector:@selector(circleViewController:annotStyle:)]) {
+            [self.delegate circleViewController:self annotStyle:self.annotStyle];
+        }
     }
 }
 

+ 0 - 15
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CSignatureDrawView.m

@@ -138,21 +138,6 @@ static NSInteger _index;
     return image;
 }
 
-//- (void)setColor:(UIColor *)color {
-//    self.color = color;
-//    [self setNeedsDisplay];
-//}
-//
-//- (void)setLineWidth:(CGFloat)lineWidth {
-//    _lineWidth = lineWidth;
-//    [self setNeedsDisplay];
-//}
-//
-//- (void)setImage:(UIImage *)image {
-//    self.image = image;
-//    [self setNeedsDisplay];
-//}
-
 #pragma mark - Action
 
 - (void)buttonItemClicked_clear:(UIButton *)button {

+ 0 - 1
compdfkit-tools/compdfkit-tools/Annotation/PDFProperties/PDFSignature/CSignatureTopBar.m

@@ -35,7 +35,6 @@
         [self.imageButton setImage:[UIImage imageNamed:@"CPDFSignatureImageImage" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
         [self.imageButton addTarget:self action:@selector(buttonItemClicked_swith:) forControlEvents:UIControlEventTouchUpInside];
         [self addSubview:self.imageButton];
-        
         self.backgroundColor = [UIColor purpleColor];
     }
     

+ 11 - 3
compdfkit-tools/compdfkit-tools/Common/Model/CAnnotStyle.h

@@ -10,14 +10,13 @@
 //  This notice may not be removed from this file.
 //
 
-#import <Foundation/Foundation.h>
-
-#import <ComPDFKit/ComPDFKit.h>
+#import <UIKit/UIKit.h>
 
 NS_ASSUME_NONNULL_BEGIN
 
 @class CPDFPage;
 @class CPDFBorder;
+@class CPDFListView;
 
 @interface CAnnotStyle : NSObject
 
@@ -45,6 +44,15 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, assign) BOOL isSelectAnnot;
 
+
+- (instancetype)initWithAnnotionMode:(NSInteger)annotionMode isSelectAnnot:(BOOL)isSelectAnnot;
+
+#pragma mark - Common
+
+- (UIColor *)color;
+- (void)setColor:(UIColor *)color;
+
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 467 - 0
compdfkit-tools/compdfkit-tools/Common/Model/CAnnotStyle.m

@@ -11,7 +11,474 @@
 //
 
 #import "CAnnotStyle.h"
+#import "CPDFListView.h"
+
+#import <ComPDFKit/ComPDFKit.h>
+
+@interface CAnnotStyle ()
+
+@property (nonatomic, strong) NSArray *headKeys;
+
+@property (nonatomic, strong) NSArray *trialKeys;
+
+@end
 
 @implementation CAnnotStyle
 
+@synthesize opacity = _opacity;
+@synthesize color = _color;
+
+- (NSArray *)headKeys {
+    if (!_headKeys) {
+        _headKeys = @[@"CPDFNone",@"CPDFNote", @"CPDFHighlight", @"CPDFUnderline", @"CPDFStrikeout", @"CPDFSquiggly", @"CPDFCircle", @"CPDFSquare", @"CPDFArrow", @"CPDFLine",@"CPDFInk", @"CPDFFreeText", @"CPDFFreeText"];
+    }
+    return _headKeys;
+}
+
+- (NSArray *)trialKeys {
+    if (!_trialKeys) {
+        _trialKeys = @[@"Color", @"Opacity", @"FillColor", @"BorderWith"];
+    }
+    return _trialKeys;
+}
+
+
+- (instancetype)initWithAnnotionMode:(NSInteger)annotionMode isSelectAnnot:(BOOL)isSelectAnnot {
+    if (self = [super init]) {
+        self.annotMode = annotionMode;
+        self.isSelectAnnot = isSelectAnnot;
+    }
+    return self;
+}
+
+- (UIColor *)color {
+    if (self.isSelectAnnot) {
+        return _color;
+    } else {
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        switch (self.annotMode) {
+            case CPDFViewAnnotationModeNote:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+            case CPDFViewAnnotationModeHighlight:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor yellowColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor yellowColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeUnderline:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor blueColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor blueColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeStrikeout:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeSquiggly:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeInk:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeCircle:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeSquare:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeArrow:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeLine:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeFreeText:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]])) {
+                    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:[UIColor redColor] requiringSecureCoding:NO error:nil];
+                    [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [UIColor redColor];
+                } else {
+                    NSData *data = [defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                    return [NSKeyedUnarchiver unarchiveObjectWithData:data];
+                }
+            }
+                break;
+            default:
+            {
+                return [UIColor clearColor];
+            }
+                break;
+        }
+        [defaults synchronize];
+            
+    }
+
+    return _color;
+}
+
+- (void)setColor:(UIColor *)color {
+    if (self.isSelectAnnot) {
+        _color = color;
+    } else {
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        switch (self.annotMode) {
+            case CPDFViewAnnotationModeNote:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+            case CPDFViewAnnotationModeHighlight:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeUnderline:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeStrikeout:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeSquiggly:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeInk:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeCircle:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeSquare:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeArrow:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeLine:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            case CPDFViewAnnotationModeFreeText:
+            {
+                NSData *data = [NSKeyedArchiver archivedDataWithRootObject:color requiringSecureCoding:NO error:nil];
+                [defaults setObject:data forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[0]]];
+                _color = color;
+            }
+                break;
+            default:
+            {
+                _color = [UIColor clearColor];
+            }
+                break;
+        }
+        [defaults synchronize];
+    }
+}
+
+
+- (CGFloat)opacity {
+    if (self.isSelectAnnot) {
+        return _opacity;
+    } else {
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+       
+        switch (self.annotMode) {
+            case CPDFViewAnnotationModeHighlight:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeUnderline:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeStrikeout:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeSquiggly:
+            {if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                return 1.0;
+            } else {
+                return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+            }
+            }
+                break;
+            case CPDFViewAnnotationModeInk:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeCircle:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeSquare:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeArrow:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeLine:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            case CPDFViewAnnotationModeFreeText:
+            {
+                if (!([defaults objectForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]])) {
+                    [defaults setFloat:1.0 forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                    return 1.0;
+                } else {
+                    return [defaults floatForKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                }
+            }
+                break;
+            default:
+                break;
+        }
+        [defaults synchronize];
+    }
+    return _opacity;
+}
+
+- (void)setOpacity:(CGFloat)opacity {
+    if (self.isSelectAnnot) {
+        _opacity = opacity;
+    } else {
+        NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+        switch (self.annotMode) {
+            case CPDFViewAnnotationModeHighlight:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeUnderline:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeStrikeout:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeSquiggly:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeInk:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeCircle:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeSquare:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeArrow:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeLine:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            case CPDFViewAnnotationModeFreeText:
+            {
+                [defaults setFloat:opacity forKey:[NSString stringWithFormat:@"%@%@", self.headKeys[self.annotMode], self.trialKeys[1]]];
+                _opacity = opacity;
+            }
+                break;
+            default:
+                break;
+        }
+        [defaults synchronize];
+    }
+}
+
 @end

+ 86 - 10
compdfkit-tools/compdfkit-tools/Common/Views/PDFAnnotationBar/CPDFAnnotationBar.m

@@ -52,8 +52,6 @@
 
 @property (nonatomic, strong) CPDFSignatureViewController *signatureVC;
 
-@property (nonatomic, strong) CPDFShapeCircleViewController *circleVC;
-
 @end
 
 @implementation CPDFAnnotationBar
@@ -80,6 +78,8 @@
         self.pdfListView = annotationManage.pdfListView;
 
         [self initSubview];
+        
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(annotationChangedNotification:) name:CPDFListViewActiveAnnotationsChangeNotification object:nil];
     }
     return self;
 }
@@ -232,13 +232,81 @@
     } else {
         self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
         self.selectedIndex = -1;
+        self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
+    }
+    
+    switch (self.selectedIndex) {
+        case CPDFToolbarNote:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeNote;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeNote];
+        }
+            break;
+        case CPDFToolbarHighlight:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeHighlight;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeNote];
+        }
+            break;
+        case CPDFToolbarUnderline:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeUnderline;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeHighlight];
+        }
+            break;
+        case CPDFToolbarStrikeout:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeStrikeout;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeStrikeout];
+        }
+            break;
+        case CPDFToolbarSquiggly:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeSquiggly;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeSquiggly];
+        }
+            break;
+        case CPDFToolbarFreehand:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeInk;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeInk];
+        }
+            break;
+        case CPDFToolbarShapeCircle:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeCircle;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeCircle];
+        }
+            break;
+        case CPDFToolbarShapeRectangle:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeSquare;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeSquare];
+        }
+            break;
+        case CPDFToolbarShapeArrow:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeArrow;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeArrow];
+        }
+            break;
+        case CPDFToolbarShapeLine:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeLine;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeLine];
+        }
+            break;
+            
+        default:
+        {
+            self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
+            [self.annotManage setAnnotStyleFromMode:CPDFViewAnnotationModeNone];
+        }
+            break;
     }
 }
 
 - (void)buttonItemClicked_open:(UIButton *)button {
-    if (self.pdfListView.activeAnnotations.firstObject) {
-        [self.annotManage setAnnotStyleFromAnnotations:self.pdfListView.activeAnnotations];
-    }
     CAnnotStyle *annotStytle = self.annotManage.annotStyle;
     AAPLCustomPresentationController *presentationController NS_VALID_UNTIL_END_OF_SCOPE;
     switch (button.tag) {
@@ -308,11 +376,11 @@
             break;
         case CPDFToolbarShapeCircle:
         {
-            self.circleVC = [[CPDFShapeCircleViewController alloc] initWithStyle:annotStytle selectIndex:CPDFToolbarShapeCircle title:@"Circle"];
-            self.circleVC.delegate = self;
-            presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:self.circleVC presentingViewController:self.parentVC];
-            self.circleVC.transitioningDelegate = presentationController;
-            [self.parentVC presentViewController:self.circleVC animated:YES completion:nil];
+            CPDFShapeCircleViewController *circleVC = [[CPDFShapeCircleViewController alloc] initWithStyle:annotStytle selectIndex:CPDFToolbarShapeCircle title:@"Circle"];
+            circleVC.delegate = self;
+            presentationController = [[AAPLCustomPresentationController alloc] initWithPresentedViewController:circleVC presentingViewController:self.parentVC];
+            circleVC.transitioningDelegate = presentationController;
+            [self.parentVC presentViewController:circleVC animated:YES completion:nil];
         }
             break;
         case CPDFToolbarShapeRectangle:
@@ -369,6 +437,14 @@
     
 }
 
+#pragma mark - NotificationCenter
+
+- (void)annotationChangedNotification:(NSNotification *)notification {
+    if (self.pdfListView.activeAnnotations.firstObject) {
+        [self.annotManage setAnnotStyleFromAnnotations:self.pdfListView.activeAnnotations];
+    }
+}
+
 #pragma mark - CPDFSignatureViewControllerDelegate
 
 - (void)signatureViewController:(CPDFSignatureViewController *)signatureViewController {

+ 25 - 10
compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFAnnotationSampleView.m

@@ -20,6 +20,8 @@
 
 @property (nonatomic, assign) CGRect arrowRect;
 
+@property (nonatomic, assign) CGRect textRect;
+
 @end
 
 @implementation CPDFAnnotationSampleView
@@ -33,12 +35,19 @@
     return self;
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    [self setNeedsDisplay];
+}
+
 - (void)drawRect:(CGRect)rect {
     [super drawRect:rect];
     CGContextRef context = UIGraphicsGetCurrentContext();
     self.centerRect = CGRectInset(rect, 130, self.bounds.size.height/3);
     self.arrowRect = CGRectInset(rect, 100, 20);
     
+    self.textRect = CGRectInset(rect, self.bounds.size.width/3, self.bounds.size.height/3);
+    
     [self drawSamples:context];
 }
 
@@ -57,29 +66,35 @@
             break;
         case CPDFSamplesHighlight:
         {
+            NSString *sampleStr = @"Sample";
             CGContextSetFillColorWithColor(context, self.fillColor.CGColor);
-            CGContextFillRect(context, self.centerRect);
-            UIImage *image = [UIImage imageNamed:@"CPDFAnnotationBarImageHighLight" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
-            [image drawInRect:self.centerRect];
+            UIFont *font = [UIFont systemFontOfSize:30];
+            NSDictionary *dic = @{NSFontAttributeName:font, NSForegroundColorAttributeName:[UIColor blackColor]};
+            CGContextFillRect(context, self.textRect);
+            [sampleStr drawInRect:self.textRect withAttributes:dic];
         }
             break;
         case CPDFSamplesUnderline:
         {
+            NSString *sampleStr = @"Sample";
             CGContextSetFillColorWithColor(context, self.fillColor.CGColor);
-            CGRect strikeoutRect = CGRectInset(self.centerRect, 0, 18);
-            CGRect underLineRect = CGRectOffset(strikeoutRect, 0, 18);
+            CGRect strikeoutRect = CGRectInset(self.textRect, 0, (self.textRect.size.height/7)*3);
+            CGRect underLineRect = CGRectOffset(strikeoutRect, 0, (self.textRect.size.height/7)*3);
             CGContextFillRect(context, underLineRect);
-            UIImage *image = [UIImage imageNamed:@"CPDFAnnotationBarImageHighLight" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
-            [image drawInRect:self.centerRect];
+            UIFont *font = [UIFont systemFontOfSize:30];
+            NSDictionary *dic = @{NSFontAttributeName:font, NSForegroundColorAttributeName:[UIColor blackColor]};
+            [sampleStr drawInRect:self.textRect withAttributes:dic];
         }
             break;
         case CPDFSamplesStrikeout:
         {
+            NSString *sampleStr = @"Sample";
             CGContextSetFillColorWithColor(context, self.fillColor.CGColor);
-            CGRect strikeoutRect = CGRectInset(self.centerRect, 0, 18);
+            CGRect strikeoutRect = CGRectInset(self.textRect, 0, (self.textRect.size.height/7)*3);
             CGContextFillRect(context, strikeoutRect);
-            UIImage *image = [UIImage imageNamed:@"CPDFAnnotationBarImageHighLight" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil];
-            [image drawInRect:self.centerRect];
+            UIFont *font = [UIFont systemFontOfSize:30];
+            NSDictionary *dic = @{NSFontAttributeName:font, NSForegroundColorAttributeName:[UIColor blackColor]};
+            [sampleStr drawInRect:self.textRect withAttributes:dic];
         }
         case CPDFSamplesSquiggly:
         {

+ 20 - 10
compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFColorSelectView.m

@@ -22,6 +22,8 @@
 @property (nonatomic, strong) UIButton *button4;
 @property (nonatomic, strong) UIButton *button5;
 @property (nonatomic, strong) UIButton *button6;
+@property (nonatomic, strong) UIButton *button7;
+@property (nonatomic, strong) UIButton *button8;
 
 @end
 
@@ -33,7 +35,7 @@
     if (self = [super initWithFrame:frame]) {
         self.colorLabel = [[UILabel alloc] init];
         self.colorLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
-        self.colorLabel.text = NSLocalizedString(@"Fill:", nil);
+        self.colorLabel.text = NSLocalizedString(@"Color", nil);
         self.colorLabel.adjustsFontSizeToFitWidth = YES;
         [self addSubview:self.colorLabel];
         
@@ -57,6 +59,12 @@
         self.button6 = [[UIButton alloc] init];
         [self.colorPickerView addSubview:self.button6];
         [self.colorArray addObject:self.button6];
+        self.button7 = [[UIButton alloc] init];
+        [self.colorPickerView addSubview:self.button7];
+        [self.colorArray addObject:self.button7];
+        self.button8 = [[UIButton alloc] init];
+        [self.colorPickerView addSubview:self.button8];
+        [self.colorArray addObject:self.button8];
         self.colorPickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
         [self addSubview:self.colorPickerView];
     }
@@ -64,21 +72,23 @@
 }
 
 - (void)pickerBarInit {
-    NSArray *colors = @[[UIColor grayColor],
-                        [UIColor redColor],
+    NSArray *colors = @[[UIColor redColor],
                         [UIColor yellowColor],
                         [UIColor blueColor],
-                        [UIColor colorWithRed:153.0/255.0 green:207.0/255.0 blue:161.0/255.0 alpha:1.0],
+                        [UIColor colorWithRed:100.0/255.0 green:188.0/255.0 blue:56.0/255.0 alpha:1.0],
+                        [UIColor colorWithRed:79.0/255.0 green:205.0/255.0 blue:160.0/255.0 alpha:1.0],
+                        [UIColor colorWithRed:255.0/255.0 green:140.0/255.0 blue:103.0/255.0 alpha:1.0],
+                        [UIColor colorWithRed:223.0/255.0 green:190.0/255.0 blue:94.0/255.0 alpha:1.0],
                         [UIColor clearColor]];
-    for (int i = 0; i < 6; i++) {
+    for (int i = 0; i < colors.count; i++) {
         UIButton *button = (UIButton *)self.colorArray[i];
-        button.frame = CGRectMake((self.bounds.size.width - 300)/7 * (i+1) + 50 * i, 5, self.colorPickerView.bounds.size.height - 10, self.colorPickerView.bounds.size.height - 10);
-        [[button layer] setCornerRadius:(self.colorPickerView.bounds.size.height - 10)/2];
+        button.frame = CGRectMake((self.bounds.size.width - ((self.colorPickerView.bounds.size.height - 20)*8))/9 * (i+1) + (self.colorPickerView.bounds.size.height - 20) * i, 5, self.colorPickerView.bounds.size.height - 20, self.colorPickerView.bounds.size.height - 20);
+        [[button layer] setCornerRadius:(self.colorPickerView.bounds.size.height - 20)/2];
         button.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin;
         button.backgroundColor = colors[i];
         button.tag = i;
         [button addTarget:self action:@selector(buttonItemClicked_select:) forControlEvents:UIControlEventTouchUpInside];
-        if (i == 5) {
+        if (i == 7) {
             [button setBackgroundImage:[UIImage imageNamed:@"CPDFColorSelectViewImageColor" inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
         }        
     }
@@ -95,14 +105,14 @@
 
 - (void)buttonItemClicked_select:(UIButton *)button {
     switch (button.tag) {
-        case 0 ... 4:
+        case 0 ... 6:
         {
             if (self.delegate && [self.delegate respondsToSelector:@selector(selectColorView:color:)]) {
                 [self.delegate selectColorView:self color:button.backgroundColor];
             }
         }
             break;
-        case 5:{
+        case 7:{
             if ([self.delegate respondsToSelector:@selector(selectColorView:)]) {
                 [self.delegate selectColorView:self];
             }

+ 0 - 2
compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFOpacitySliderView.h

@@ -32,8 +32,6 @@ NS_ASSUME_NONNULL_BEGIN
 
 @property (nonatomic, strong) UILabel *startLabel;
 
-@property (nonatomic, strong) UILabel *endLabel;
-
 @property (nonatomic, weak) id<CPDFOpacitySliderViewDelegate> delegate;
 
 @end

+ 17 - 9
compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFOpacitySliderView.m

@@ -18,13 +18,13 @@
 
 - (instancetype)initWithFrame:(CGRect)frame {
     if (self = [super initWithFrame:frame]) {
-        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 50, 30)];
+        self.titleLabel = [[UILabel alloc] init];
         self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
         self.titleLabel.text = NSLocalizedString(@"Opacity:", nil);
         self.titleLabel.adjustsFontSizeToFitWidth = YES;
         [self addSubview:self.titleLabel];
         
-        self.opacitySlider = [[UISlider alloc] initWithFrame:CGRectMake(5, 30, self.frame.size.width - 10, 30)];
+        self.opacitySlider = [[UISlider alloc] init];
         self.opacitySlider.autoresizingMask = UIViewAutoresizingFlexibleWidth;
         self.opacitySlider.value = 1;
         self.opacitySlider.maximumValue = 1;
@@ -32,22 +32,30 @@
         [self.opacitySlider addTarget:self action:@selector(buttonItemClicked_changes:) forControlEvents:UIControlEventValueChanged];
         [self addSubview:self.opacitySlider];
         
-        self.startLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 60, 30, 20)];
-        self.startLabel.text = NSLocalizedString(@"0", nil);
+        self.startLabel = [[UILabel alloc] init];
+        self.startLabel.text = NSLocalizedString(@"100%", nil);
+        self.startLabel.layer.borderWidth = 1.0;
+        self.startLabel.textAlignment = NSTextAlignmentCenter;
+        self.startLabel.layer.cornerRadius = 6.0;
+        self.startLabel.layer.masksToBounds = YES;
+        self.startLabel.layer.borderColor = [UIColor grayColor].CGColor;
         self.startLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
         [self addSubview:self.startLabel];
-        
-        self.endLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 35, 60, 30, 20)];
-        self.endLabel.text = NSLocalizedString(@"1", nil);
-        self.endLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
-        [self addSubview:self.endLabel];
     }
     return self;
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    self.titleLabel.frame = CGRectMake(10, 0, 50, self.frame.size.height/2);
+    self.opacitySlider.frame = CGRectMake(10, self.frame.size.height/2, self.frame.size.width - 110, self.frame.size.height/2);
+    self.startLabel.frame = CGRectMake(self.frame.size.width - 90, self.frame.size.height/2, 80, self.frame.size.height/2);
+}
+
 #pragma mark - Action
 
 - (void)buttonItemClicked_changes:(UISlider *)sender {
+    self.startLabel.text = [NSString stringWithFormat:@"%d%%", (int)((sender.value/1)*100)];
     if (self.delegate && [self.delegate respondsToSelector:@selector(opacitySliderView:opacity:)]) {
         [self.delegate opacitySliderView:self opacity:sender.value];
     }

+ 17 - 10
compdfkit-tools/compdfkit-tools/Common/Views/PDFProperties/CPDFThicknessSliderView.m

@@ -18,35 +18,42 @@
 
 - (instancetype)initWithFrame:(CGRect)frame {
     if (self = [super initWithFrame:frame]) {
-        self.titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 50, 30)];
-        self.titleLabel.text = NSLocalizedString(@"Dotted:", nil);
+        self.titleLabel = [[UILabel alloc] init];
+        self.titleLabel.text = NSLocalizedString(@"Thickeness", nil);
         self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
         self.titleLabel.adjustsFontSizeToFitWidth = YES;
         [self addSubview:self.titleLabel];
         
-        self.thicknessSlider = [[UISlider alloc] initWithFrame:CGRectMake(5, 30, self.frame.size.width - 10, 30)];
+        self.thicknessSlider = [[UISlider alloc] init];
         self.thicknessSlider.autoresizingMask = UIViewAutoresizingFlexibleWidth;
         self.thicknessSlider.maximumValue = 10.0;
         self.thicknessSlider.minimumValue = 1.0;
         [self.thicknessSlider addTarget:self action:@selector(buttonItemClicked_changes:) forControlEvents:UIControlEventValueChanged];
         [self addSubview:self.thicknessSlider];
         
-        self.startLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, 60, 30, 20)];
-        self.startLabel.text = NSLocalizedString(@"1", nil);
+        self.startLabel = [[UILabel alloc] init];
+        self.startLabel.text = NSLocalizedString(@"10pt", nil);
+        self.startLabel.layer.borderWidth = 1.0;
+        self.startLabel.textAlignment = NSTextAlignmentCenter;
+        self.startLabel.layer.cornerRadius = 6.0;
+        self.startLabel.layer.masksToBounds = YES;
         self.startLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
         [self addSubview:self.startLabel];
-        
-        self.endLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.bounds.size.width - 35, 60, 30, 20)];
-        self.endLabel.text = NSLocalizedString(@"10", nil);
-        self.endLabel.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin;
-        [self addSubview:self.endLabel];
     }
     return self;
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    self.titleLabel.frame = CGRectMake(10, 0, 50, self.frame.size.height/2);
+    self.thicknessSlider.frame = CGRectMake(10, self.frame.size.height/2, self.frame.size.width - 110, self.frame.size.height/2);
+    self.startLabel.frame = CGRectMake(self.frame.size.width - 90, self.frame.size.height/2, 80, self.frame.size.height/2);
+}
+
 #pragma mark - Action
 
 - (void)buttonItemClicked_changes:(UISlider *)sender {
+    self.startLabel.text = [NSString stringWithFormat:@"%.1fpt", sender.value];
     if (self.delegate && [self.delegate respondsToSelector:@selector(thicknessSliderView:thickness:)]) {
         [self.delegate thicknessSliderView:self thickness:sender.value];
     }

+ 1 - 1
compdfkit-tools/compdfkit-tools/Edit/CPDFEditCell/CPDFTextPropertyCell.m

@@ -52,7 +52,7 @@
         self.opacityView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
         self.opacityView.titleLabel.text = NSLocalizedString(@"Font Size:", nil);
         self.opacityView.startLabel.text = @"0";
-        self.opacityView.endLabel.text = @"100";
+//        self.opacityView.endLabel.text = @"100";
         self.opacityView.opacitySlider.value = 0.14;
         self.opacityView.delegate = self;
         [self.sliderArea addSubview:self.opacityView];