|
@@ -92,12 +92,24 @@
|
|
|
#pragma mark - Public Methods
|
|
|
|
|
|
- (void)reloadData {
|
|
|
- if (self.selectedIndex >=0 &&
|
|
|
- self.selectedIndex < self.annotationBtns.count) {
|
|
|
- UIButton *selectedButton = [self.annotationBtns objectAtIndex:self.selectedIndex];
|
|
|
- selectedButton.backgroundColor = [UIColor clearColor];
|
|
|
+ if(CPDFViewAnnotationModeNone == self.pdfListView.annotationMode) {
|
|
|
+ if (self.selectedIndex >=0 &&
|
|
|
+ self.selectedIndex < self.annotationBtns.count) {
|
|
|
+ UIButton *selectedButton = [self.annotationBtns objectAtIndex:self.selectedIndex];
|
|
|
+ selectedButton.backgroundColor = [UIColor clearColor];
|
|
|
+ }
|
|
|
+ self.selectedIndex = -1;
|
|
|
+ } else {
|
|
|
+ for (NSInteger i = 0; i< self.annotationBtns.count; i++) {
|
|
|
+ UIButton *button = [self.annotationBtns objectAtIndex:i];
|
|
|
+ if(button.tag == self.pdfListView.annotationMode) {
|
|
|
+ button.backgroundColor = [UIColor colorWithRed:178.0/255.0 green:239.0/255.0 blue:253.0/255.0 alpha:1.0];
|
|
|
+ self.selectedIndex = button.tag;
|
|
|
+ } else {
|
|
|
+ button.backgroundColor = [UIColor clearColor];
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- self.selectedIndex = -1;
|
|
|
}
|
|
|
|
|
|
#pragma mark - Private Methods
|
|
@@ -126,23 +138,39 @@
|
|
|
@"CPDFAnnotationBarImageLink",
|
|
|
@"CPDFAnnotationBarImageSound"];
|
|
|
|
|
|
+ NSArray *types = @[@(CPDFViewAnnotationModeNote),
|
|
|
+ @(CPDFViewAnnotationModeHighlight),
|
|
|
+ @(CPDFViewAnnotationModeUnderline),
|
|
|
+ @(CPDFViewAnnotationModeStrikeout),
|
|
|
+ @(CPDFViewAnnotationModeSquiggly),
|
|
|
+ @(CPDFViewAnnotationModeInk),
|
|
|
+ @(CPDFViewAnnotationModeCircle),
|
|
|
+ @(CPDFViewAnnotationModeSquare),
|
|
|
+ @(CPDFViewAnnotationModeArrow),
|
|
|
+ @(CPDFViewAnnotationModeLine),
|
|
|
+ @(CPDFViewAnnotationModeFreeText),
|
|
|
+ @(CPDFViewAnnotationModeSignature),
|
|
|
+ @(CPDFViewAnnotationModeStamp),
|
|
|
+ @(CPDFViewAnnotationModeImage),
|
|
|
+ @(CPDFViewAnnotationModeLink),
|
|
|
+ @(CPDFViewAnnotationModeSound)];
|
|
|
+
|
|
|
NSMutableArray *annotationBtns = [NSMutableArray array];
|
|
|
- for (int i = 0; i < images.count; i++) {
|
|
|
+ for (int i = 0; i < types.count; i++) {
|
|
|
+ CPDFViewAnnotationMode annotationMode = (CPDFViewAnnotationMode)[types[i] integerValue];
|
|
|
CPDFAnnotationBarButton *button = [CPDFAnnotationBarButton buttonWithType:UIButtonTypeCustom];
|
|
|
button.frame = CGRectMake(offsetX, 1, 58, 43);
|
|
|
[button setImage:[UIImage imageNamed:images[i] inBundle:[NSBundle bundleForClass:self.class] compatibleWithTraitCollection:nil] forState:UIControlStateNormal];
|
|
|
- button.tag = i;
|
|
|
- button.type = i;
|
|
|
- if (i == 1) {
|
|
|
+ button.tag = annotationMode;
|
|
|
+ if (CPDFViewAnnotationModeHighlight == annotationMode) {
|
|
|
button.lineColor = CPDFKitShareConfig.highlightAnnotationColor;
|
|
|
- } else if (i == 2) {
|
|
|
+ } else if (CPDFViewAnnotationModeUnderline == annotationMode) {
|
|
|
button.lineColor = CPDFKitShareConfig.underlineAnnotationColor;
|
|
|
- } else if (i == 3) {
|
|
|
+ } else if (CPDFViewAnnotationModeStrikeout == annotationMode) {
|
|
|
button.lineColor = CPDFKitShareConfig.strikeoutAnnotationColor;
|
|
|
- } else if (i == 4) {
|
|
|
+ } else if (CPDFViewAnnotationModeSquiggly == annotationMode) {
|
|
|
button.lineColor = CPDFKitShareConfig.squigglyAnnotationColor;
|
|
|
- } else if (i == 5) {
|
|
|
- button.type = 4;
|
|
|
+ } else if (CPDFViewAnnotationModeInk== annotationMode) {
|
|
|
button.lineColor = CPDFKitShareConfig.freehandAnnotationColor;
|
|
|
}
|
|
|
[button addTarget:self action:@selector(buttonItemClicked_Switch:) forControlEvents:UIControlEventTouchUpInside];
|
|
@@ -191,7 +219,7 @@
|
|
|
- (void)buttonItemClicked_Switch:(UIButton *)button {
|
|
|
self.propertiesBtn.userInteractionEnabled = YES;
|
|
|
self.propertiesBtn.tag = button.tag;
|
|
|
- if (self.selectedIndex >= 0 && self.selectedIndex < self.annotationBtns.count) {
|
|
|
+ if (self.selectedIndex >= 0 && self.selectedIndex <= self.annotationBtns.count) {
|
|
|
UIButton *selectButton = [self.annotationBtns objectAtIndex:self.selectedIndex];
|
|
|
selectButton.backgroundColor = [UIColor clearColor];
|
|
|
}
|
|
@@ -199,68 +227,12 @@
|
|
|
if (button.tag != self.selectedIndex) {
|
|
|
button.backgroundColor = [UIColor colorWithRed:178.0/255.0 green:239.0/255.0 blue:253.0/255.0 alpha:1.0];
|
|
|
self.selectedIndex = button.tag;
|
|
|
+ self.pdfListView.annotationMode = self.selectedIndex;
|
|
|
+
|
|
|
} else {
|
|
|
+ self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
|
|
|
self.selectedIndex = -1;
|
|
|
}
|
|
|
-
|
|
|
- switch (self.selectedIndex) {
|
|
|
- case CPDFToolbarNote:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeNote;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarHighlight:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeHighlight;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarUnderline:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeUnderline;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarStrikeout:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeStrikeout;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarSquiggly:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeSquiggly;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarFreehand:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeInk;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarShapeCircle:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeCircle;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarShapeRectangle:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeSquare;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarShapeArrow:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeArrow;
|
|
|
- }
|
|
|
- break;
|
|
|
- case CPDFToolbarShapeLine:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeLine;
|
|
|
- }
|
|
|
- break;
|
|
|
-
|
|
|
- default:
|
|
|
- {
|
|
|
- self.pdfListView.annotationMode = CPDFViewAnnotationModeNone;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
- (void)buttonItemClicked_open:(UIButton *)button {
|