|
@@ -18,6 +18,7 @@
|
|
|
#import <ComPDFKit/ComPDFKit.h>
|
|
|
#import "CPDFColorUtils.h"
|
|
|
#import "CPDFEditTextSampleView.h"
|
|
|
+#import "CPDFEditImageSampleView.h"
|
|
|
|
|
|
@interface CPDFEditViewController ()<UITableViewDelegate,UITableViewDataSource,CPDFColorPickerViewDelegate,CPDFEditFontNameSelectViewDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate,UIColorPickerViewControllerDelegate>
|
|
|
|
|
@@ -27,6 +28,7 @@
|
|
|
@property (nonatomic, strong) CPDFEditFontNameSelectView * fontSelectView;
|
|
|
@property (nonatomic, strong) UIButton *backBtn;
|
|
|
@property (nonatomic, strong) CPDFEditTextSampleView * textSampleView;
|
|
|
+@property (nonatomic, strong) CPDFEditImageSampleView * imageSampleView;
|
|
|
|
|
|
@end
|
|
|
|
|
@@ -65,9 +67,9 @@
|
|
|
self.titleLabel = [[UILabel alloc] init];
|
|
|
self.titleLabel.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
|
|
if(self.editMode == CPDFEditModeText){
|
|
|
- self.titleLabel.text = NSLocalizedString(@"Text Property", nil);
|
|
|
+ self.titleLabel.text = NSLocalizedString(@"Text Properties", nil);
|
|
|
}else{
|
|
|
- self.titleLabel.text = NSLocalizedString(@"Image Property", nil);
|
|
|
+ self.titleLabel.text = NSLocalizedString(@"Image Properties", nil);
|
|
|
}
|
|
|
self.titleLabel.font = [UIFont systemFontOfSize:20];
|
|
|
self.titleLabel.adjustsFontSizeToFitWidth = YES;
|
|
@@ -128,45 +130,77 @@
|
|
|
- (void)updatePreferredContentSizeWithTraitCollection:(UITraitCollection *)traitCollection
|
|
|
{
|
|
|
if(self.editMode == CPDFEditModeText){
|
|
|
- self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 300 : 400);
|
|
|
+ self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 300 : 600);
|
|
|
}else{
|
|
|
- self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 300 : 400);
|
|
|
+ self.preferredContentSize = CGSizeMake(self.view.bounds.size.width, traitCollection.verticalSizeClass == UIUserInterfaceSizeClassCompact ? 300 : 520);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
|
|
|
- UIView * view = [[UIView alloc] initWithFrame:CGRectMake(20, 0, self.view.bounds.size.width-40, 120)];
|
|
|
- view.backgroundColor = [UIColor whiteColor];
|
|
|
- view.layer.borderWidth = 1.0;
|
|
|
- view.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
|
|
|
- view.backgroundColor = [CPDFColorUtils CAnnotationSampleBackgoundColor];
|
|
|
-
|
|
|
- self.textSampleView = [[CPDFEditTextSampleView alloc] init];
|
|
|
- self.textSampleView.backgroundColor = [UIColor whiteColor];
|
|
|
- self.textSampleView.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
|
|
|
- self.textSampleView.layer.borderWidth = 1.0;
|
|
|
- self.textSampleView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
|
|
- self.textSampleView.frame = CGRectMake((self.view.frame.size.width - 300)/2, 15, 300, view.bounds.size.height - 30);
|
|
|
-
|
|
|
- self.textSampleView.textAlignmnet = self.pdfView.editingSelectionAlignment;
|
|
|
- self.textSampleView.textColor = self.pdfView.editingSelectionFontColor;
|
|
|
- self.textSampleView.textOpacity = [self.pdfView getCurrentOpacity];
|
|
|
- self.textSampleView.fontName = self.pdfView.editingSelectionFontName;
|
|
|
- self.textSampleView.isBold = self.pdfView.isBoldCurrentSelection;
|
|
|
- self.textSampleView.isItalic = self.pdfView.isItalicCurrentSelection;
|
|
|
- self.textSampleView.fontSize = self.pdfView.editingSelectionFontSize;
|
|
|
-
|
|
|
- [view addSubview:self.textSampleView];
|
|
|
- return view;
|
|
|
+ if(self.editMode == CPDFEditModeText){
|
|
|
+ UIView * view = [[UIView alloc] initWithFrame:CGRectMake(20, 0, self.view.bounds.size.width-40, 120)];
|
|
|
+ view.backgroundColor = [UIColor whiteColor];
|
|
|
+ view.layer.borderWidth = 1.0;
|
|
|
+ view.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
|
|
|
+ view.backgroundColor = [CPDFColorUtils CAnnotationSampleBackgoundColor];
|
|
|
+
|
|
|
+ self.textSampleView = [[CPDFEditTextSampleView alloc] init];
|
|
|
+ self.textSampleView.backgroundColor = [UIColor whiteColor];
|
|
|
+ self.textSampleView.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
|
|
|
+ self.textSampleView.layer.borderWidth = 1.0;
|
|
|
+ self.textSampleView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
|
|
+ self.textSampleView.frame = CGRectMake((self.view.frame.size.width - 300)/2, 15, 300, view.bounds.size.height - 30);
|
|
|
+
|
|
|
+ self.textSampleView.textAlignmnet = self.pdfView.editingSelectionAlignment;
|
|
|
+ self.textSampleView.textColor = self.pdfView.editingSelectionFontColor;
|
|
|
+ self.textSampleView.textOpacity = [self.pdfView getCurrentOpacity];
|
|
|
+ self.textSampleView.fontName = self.pdfView.editingSelectionFontName;
|
|
|
+ self.textSampleView.isBold = self.pdfView.isBoldCurrentSelection;
|
|
|
+ self.textSampleView.isItalic = self.pdfView.isItalicCurrentSelection;
|
|
|
+ self.textSampleView.fontSize = self.pdfView.editingSelectionFontSize;
|
|
|
+
|
|
|
+ [view addSubview:self.textSampleView];
|
|
|
+
|
|
|
+ return view;
|
|
|
+ } else {
|
|
|
+ UIView * view = [[UIView alloc] initWithFrame:CGRectMake(20, 0, self.view.bounds.size.width-40, 120)];
|
|
|
+ view.backgroundColor = [UIColor whiteColor];
|
|
|
+ view.layer.borderWidth = 1.0;
|
|
|
+ view.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
|
|
|
+ view.backgroundColor = [CPDFColorUtils CAnnotationSampleBackgoundColor];
|
|
|
+
|
|
|
+ self.imageSampleView = [[CPDFEditImageSampleView alloc] init];
|
|
|
+ self.imageSampleView.backgroundColor = [UIColor whiteColor];
|
|
|
+ self.imageSampleView.layer.borderColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1].CGColor;
|
|
|
+ self.imageSampleView.layer.borderWidth = 1.0;
|
|
|
+ self.imageSampleView.autoresizingMask = UIViewAutoresizingFlexibleRightMargin;
|
|
|
+ self.imageSampleView.frame = CGRectMake((self.view.frame.size.width - 300)/2, 15, 300, view.bounds.size.height - 30);
|
|
|
+
|
|
|
+ if ([self.pdfView getRotationEditArea:(CPDFEditImageArea *)self.pdfView.editingArea] > 0) {
|
|
|
+ if ([self.pdfView getRotationEditArea:(CPDFEditImageArea *)self.pdfView.editingArea] > 90) {
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformRotate(self.imageSampleView.imageView.transform, M_PI);
|
|
|
+ } else {
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformRotate(self.imageSampleView.imageView.transform, M_PI/2);
|
|
|
+ }
|
|
|
+ } else if (([self.pdfView getRotationEditArea:(CPDFEditImageArea *)self.pdfView.editingArea] < 0)) {
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformRotate(self.imageSampleView.imageView.transform, -M_PI/2);
|
|
|
+ }
|
|
|
+// self.imageSampleView.transFormType = 0;
|
|
|
+ self.imageSampleView.imageView.alpha = [self.pdfView getCurrentOpacity];
|
|
|
+
|
|
|
+ [view addSubview:self.imageSampleView];
|
|
|
+
|
|
|
+ return view;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
|
|
|
if(self.editMode == CPDFEditModeText){
|
|
|
return 120;
|
|
|
}else{
|
|
|
- return 0;
|
|
|
+ return 120;
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -262,21 +296,31 @@
|
|
|
cell.rotateBlock = ^(CPDFImageRotateType rotateType, BOOL isRotated) {
|
|
|
if(rotateType == CPDFImageRotateTypeLeft){
|
|
|
[self.pdfView rotateEditArea:(CPDFEditImageArea*)self.pdfView.editingArea rotateAngle:-90];
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformRotate(self.imageSampleView.imageView.transform, -M_PI/2);
|
|
|
+ [self.imageSampleView setNeedsLayout];
|
|
|
}else if(rotateType == CPDFImageRotateTypeRight){
|
|
|
[self.pdfView rotateEditArea:(CPDFEditImageArea*)self.pdfView.editingArea rotateAngle:90];
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformRotate(self.imageSampleView.imageView.transform, M_PI/2);
|
|
|
+ [self.imageSampleView setNeedsLayout];
|
|
|
}
|
|
|
};
|
|
|
|
|
|
cell.transFormBlock = ^(CPDFImageTransFormType transformType, BOOL isTransformed) {
|
|
|
if(transformType == CPDFImageTransFormTypeVertical){
|
|
|
[self.pdfView verticalMirrorEditArea:(CPDFEditImageArea*)self.pdfView.editingArea];
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformScale(self.imageSampleView.imageView.transform, 1.0, -1.0);
|
|
|
+ [self.imageSampleView setNeedsLayout];
|
|
|
}else if(transformType == CPDFImageTransFormTypeHorizontal){
|
|
|
[self.pdfView horizontalMirrorEditArea:(CPDFEditImageArea*)self.pdfView.editingArea];
|
|
|
+ self.imageSampleView.imageView.transform = CGAffineTransformScale(self.imageSampleView.imageView.transform, -1.0, 1.0);
|
|
|
+ [self.imageSampleView setNeedsLayout];
|
|
|
}
|
|
|
};
|
|
|
|
|
|
cell.transparencyBlock = ^(CGFloat transparency) {
|
|
|
[self.pdfView setImageTransparencyEditArea:(CPDFEditImageArea*)self.pdfView.editingArea transparency:transparency];
|
|
|
+ self.imageSampleView.imageView.alpha = transparency;
|
|
|
+ [self.imageSampleView setNeedsLayout];
|
|
|
};
|
|
|
|
|
|
cell.replaceImageBlock = ^{
|
|
@@ -294,7 +338,7 @@
|
|
|
cell.exportImageBlock = ^{
|
|
|
BOOL saved = [self.pdfView extractImageWithEditImageArea:self.pdfView.editingArea];
|
|
|
if(saved){
|
|
|
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"Saved Success!", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"Export Successfully!", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK!", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
[self controllerDismiss];
|
|
@@ -302,7 +346,7 @@
|
|
|
|
|
|
[self presentViewController:alertController animated:YES completion:nil];
|
|
|
}else{
|
|
|
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"Saved Failed!", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
+ UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:NSLocalizedString(@"Export Failed!", nil) preferredStyle:UIAlertControllerStyleAlert];
|
|
|
|
|
|
[alertController addAction:[UIAlertAction actionWithTitle:NSLocalizedString(@"OK!", nil) style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
|
[self controllerDismiss];
|
|
@@ -345,6 +389,13 @@
|
|
|
- (void)colorPickerViewControllerDidFinish:(UIColorPickerViewController *)viewController API_AVAILABLE(ios(14.0)) {
|
|
|
self.textSampleView.textColor = viewController.selectedColor;
|
|
|
[self.pdfView setEditingSelectionFontColor:viewController.selectedColor];
|
|
|
+
|
|
|
+ CGFloat red, green, blue, alpha;
|
|
|
+ [viewController.selectedColor getRed:&red green:&green blue:&blue alpha:&alpha];
|
|
|
+
|
|
|
+ self.textSampleView.textOpacity = alpha;
|
|
|
+ [self.pdfView setCharsFontTransparency:alpha];
|
|
|
+ [self.tableView reloadData];
|
|
|
}
|
|
|
|
|
|
#pragma mark - setMode
|