Browse Source

PDFView(ios) - 修改后第二版(封装与继承)

yangliuhua 2 years ago
parent
commit
09624ca4ec

+ 8 - 8
PDFViewer.xcodeproj/project.pbxproj

@@ -21,6 +21,7 @@
 		C993B90C29271FCA00D8F474 /* CPDFBatesAddViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */; };
 		C993B90F2927200400D8F474 /* CPDFBatesAddView.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90E2927200400D8F474 /* CPDFBatesAddView.m */; };
 		C993B918292B5BC500D8F474 /* CPDFHeaderFooterModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */; };
+		C9AF3143293E032500CE0313 /* CPDFAddView.m in Sources */ = {isa = PBXBuildFile; fileRef = C9AF3142293E032500CE0313 /* CPDFAddView.m */; };
 		C9E65160292CBC31001B2C9D /* MASViewConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E65146292CBC2F001B2C9D /* MASViewConstraint.m */; };
 		C9E65161292CBC31001B2C9D /* NSLayoutConstraint+MASDebugAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E65148292CBC2F001B2C9D /* NSLayoutConstraint+MASDebugAdditions.m */; };
 		C9E65162292CBC31001B2C9D /* View+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E65149292CBC30001B2C9D /* View+MASAdditions.m */; };
@@ -31,7 +32,6 @@
 		C9E65168292CBC31001B2C9D /* MASLayoutConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E65159292CBC31001B2C9D /* MASLayoutConstraint.m */; };
 		C9E65169292CBC31001B2C9D /* MASCompositeConstraint.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6515B292CBC31001B2C9D /* MASCompositeConstraint.m */; };
 		C9E6516A292CBC31001B2C9D /* NSArray+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6515C292CBC31001B2C9D /* NSArray+MASAdditions.m */; };
-		C9E6516D292F4EB5001B2C9D /* CPDFBatesModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6516C292F4EB5001B2C9D /* CPDFBatesModel.m */; };
 		C9E6517029306274001B2C9D /* CPDFHeaderFooterTextTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6516F29306274001B2C9D /* CPDFHeaderFooterTextTableView.m */; };
 		C9E6517329308A6C001B2C9D /* CPDFPageFomatModel.m in Sources */ = {isa = PBXBuildFile; fileRef = C9E6517229308A6C001B2C9D /* CPDFPageFomatModel.m */; };
 		EC62978E29220F8300D339EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EC62978D29220F8300D339EE /* AppDelegate.m */; };
@@ -82,6 +82,8 @@
 		C993B90E2927200400D8F474 /* CPDFBatesAddView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesAddView.m; sourceTree = "<group>"; };
 		C993B916292B5BC500D8F474 /* CPDFHeaderFooterModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterModel.h; sourceTree = "<group>"; };
 		C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterModel.m; sourceTree = "<group>"; };
+		C9AF3141293E032500CE0313 /* CPDFAddView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFAddView.h; sourceTree = "<group>"; };
+		C9AF3142293E032500CE0313 /* CPDFAddView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFAddView.m; sourceTree = "<group>"; };
 		C9E65146292CBC2F001B2C9D /* MASViewConstraint.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASViewConstraint.m; sourceTree = "<group>"; };
 		C9E65147292CBC2F001B2C9D /* NSArray+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSArray+MASAdditions.h"; sourceTree = "<group>"; };
 		C9E65148292CBC2F001B2C9D /* NSLayoutConstraint+MASDebugAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSLayoutConstraint+MASDebugAdditions.m"; sourceTree = "<group>"; };
@@ -107,8 +109,6 @@
 		C9E6515D292CBC31001B2C9D /* MASCompositeConstraint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASCompositeConstraint.h; sourceTree = "<group>"; };
 		C9E6515E292CBC31001B2C9D /* MASViewAttribute.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASViewAttribute.h; sourceTree = "<group>"; };
 		C9E6515F292CBC31001B2C9D /* MASConstraint+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASConstraint+Private.h"; sourceTree = "<group>"; };
-		C9E6516B292F4EB5001B2C9D /* CPDFBatesModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesModel.h; sourceTree = "<group>"; };
-		C9E6516C292F4EB5001B2C9D /* CPDFBatesModel.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesModel.m; sourceTree = "<group>"; };
 		C9E6516E29306274001B2C9D /* CPDFHeaderFooterTextTableView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterTextTableView.h; sourceTree = "<group>"; };
 		C9E6516F29306274001B2C9D /* CPDFHeaderFooterTextTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterTextTableView.m; sourceTree = "<group>"; };
 		C9E6517129308A6C001B2C9D /* CPDFPageFomatModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFPageFomatModel.h; sourceTree = "<group>"; };
@@ -241,12 +241,10 @@
 				EC6297B7292239A700D339EE /* CPDFModel.m */,
 				C993B916292B5BC500D8F474 /* CPDFHeaderFooterModel.h */,
 				C993B917292B5BC500D8F474 /* CPDFHeaderFooterModel.m */,
-				C9E6516B292F4EB5001B2C9D /* CPDFBatesModel.h */,
-				C9E6516C292F4EB5001B2C9D /* CPDFBatesModel.m */,
+				C94D478A29344878008983FB /* CPDFFontNameModel.h */,
+				C94D478B29344878008983FB /* CPDFFontNameModel.m */,
 				C9E6517129308A6C001B2C9D /* CPDFPageFomatModel.h */,
 				C9E6517229308A6C001B2C9D /* CPDFPageFomatModel.m */,
-				C94D478B29344878008983FB /* CPDFFontNameModel.m */,
-				C94D478A29344878008983FB /* CPDFFontNameModel.h */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -261,6 +259,8 @@
 				C993B90E2927200400D8F474 /* CPDFBatesAddView.m */,
 				C9E6516E29306274001B2C9D /* CPDFHeaderFooterTextTableView.h */,
 				C9E6516F29306274001B2C9D /* CPDFHeaderFooterTextTableView.m */,
+				C9AF3141293E032500CE0313 /* CPDFAddView.h */,
+				C9AF3142293E032500CE0313 /* CPDFAddView.m */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -369,13 +369,13 @@
 				EC62979429220F8300D339EE /* ViewController.m in Sources */,
 				EC6297B8292239A700D339EE /* CPDFModel.m in Sources */,
 				C9E65167292CBC31001B2C9D /* MASConstraint.m in Sources */,
+				C9AF3143293E032500CE0313 /* CPDFAddView.m in Sources */,
 				C9E65163292CBC31001B2C9D /* MASViewAttribute.m in Sources */,
 				C9E65165292CBC31001B2C9D /* MASConstraintMaker.m in Sources */,
 				C9E65162292CBC31001B2C9D /* View+MASAdditions.m in Sources */,
 				C9E65161292CBC31001B2C9D /* NSLayoutConstraint+MASDebugAdditions.m in Sources */,
 				C993B90C29271FCA00D8F474 /* CPDFBatesAddViewController.m in Sources */,
 				C9E65166292CBC31001B2C9D /* ViewController+MASAdditions.m in Sources */,
-				C9E6516D292F4EB5001B2C9D /* CPDFBatesModel.m in Sources */,
 				C9E65160292CBC31001B2C9D /* MASViewConstraint.m in Sources */,
 				C94D478C29344878008983FB /* CPDFFontNameModel.m in Sources */,
 				C9E65168292CBC31001B2C9D /* MASLayoutConstraint.m in Sources */,

BIN
PDFViewer.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile_2.xcuserdatad/UserInterfaceState.xcuserstate


+ 2 - 15
PDFViewer/Controller/CPDFBatesAddViewController.h

@@ -8,25 +8,12 @@
 #import <UIKit/UIKit.h>
 #import "CPDFBatesAddView.h"
 #import "CPDFHeaderFooterAddController.h"
-#import "CPDFBatesModel.h"
-#import "CPDFHeaderFooterTextTableView.h"
 #import "CPDFFontNameModel.h"
 
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFBatesAddViewController : UIViewController <UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
 
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
+NS_ASSUME_NONNULL_BEGIN
 
-@property (nonatomic,strong) UIImage *image;
-@property (nonatomic,assign) CGSize size;
-@property (nonatomic,assign) PositionRec position;
-@property (nonatomic,strong) CPDFBatesAddView *batesAddView;
-@property (nonatomic,strong) UILabel *showLabel;
-@property (nonatomic,strong) UIImageView *imageView;
-@property (nonatomic,strong) CPDFBatesModel *modelBatesData;
-@property (nonatomic,strong) CPDFHeaderFooterTextTableView *fontName;
-@property (nonatomic,strong) NSMutableArray *dataArray;
+@interface CPDFBatesAddViewController : CPDFHeaderFooterAddController <UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
 
 @end
 

+ 42 - 177
PDFViewer/Controller/CPDFBatesAddViewController.m

@@ -9,62 +9,62 @@
 
 @interface CPDFBatesAddViewController ()
 
+@property (nonatomic,strong) CPDFHeaderFooterTextTableView *fontName;
+@property (nonatomic,strong) NSMutableArray *dataArray;
+@property (nonatomic,strong) CPDFBatesAddView *batesAddView;
+
 @end
 
 @implementation CPDFBatesAddViewController
 
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size {
-    self = [super init];
-    if (self) {
-        _image = image;
-        _size  = size;
-    }
-    return self;
-}
-
 - (void)viewDidLoad {
     [super viewDidLoad];
     // Do any additional setup after loading the view.
+}
+
+#pragma mark - Initializers
+
+- (void)initNavigation {
     self.navigationItem.title = @"Add Bates";
     self.navigationController.toolbarHidden = YES;
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneBatesClick:)];
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelClick:)];
-    
-    // Initialize model
-    _modelBatesData = [[CPDFBatesModel alloc] init];
-    _modelBatesData.fontName = @"Helvetica";
-    _modelBatesData.fontPosition = 1;
-    _modelBatesData.fontText = @"#2#1#0#0";
-    _modelBatesData.fontColor = [UIColor blackColor];
-    
-    // Add page image
-    _imageView = [[UIImageView alloc] init];
-    _imageView.image = self.image;
-    CALayer *layer = [_imageView layer];
-    layer.borderColor = [[UIColor blackColor] CGColor];
-    layer.borderWidth = 0.5f;
-    [self.view addSubview:_imageView];
+}
+
+- (void)initModel {
+    self.modelData = [[CPDFHeaderFooterModel alloc] init];
+    self.modelData.fontName = @"Helvetica";
+    self.modelData.fontPosition = 1;
+    self.modelData.fontText = @"#2#1#0#0";
+    self.modelData.fontColor = [UIColor blackColor];
+}
+
+- (void)initShowLabel {
+    self.showLabel = [[UILabel alloc] init];
+    [self.showLabel setText:@"0010"];
+    self.showLabel.font = [UIFont systemFontOfSize:5];
+}
+
+- (void)initBttonmView {
     _batesAddView = [[CPDFBatesAddView alloc] init];
+    [_batesAddView setText];
     [self.view addSubview:_batesAddView];
-    [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
-        make.top.equalTo(self.view.mas_top).offset(125);
-        make.left.equalTo(self.view.mas_left).offset((393/2)-(self.size.width/6));
-        make.width.mas_equalTo(self.size.width/3);
-        make.height.mas_equalTo(self.size.height/3);
-    }];
     
-    // Add view
     [self.batesAddView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.imageView.mas_bottom).offset(60);
         make.left.equalTo(self.view.mas_left);
         make.width.mas_equalTo(self.view.frame.size.width);
         make.height.mas_equalTo(self.view.frame.size.height);
     }];
-    
-    // UI event
-    [ _batesAddView.localSegment addTarget:self action:@selector(changeLocation:) forControlEvents:UIControlEventValueChanged];
-    [ _batesAddView.aligbmentSegment addTarget:self action:@selector(changeAligbment:) forControlEvents:UIControlEventValueChanged];
-    [ _batesAddView.colorSlider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
+}
+
+- (void)initBasicEvent {
+    [_batesAddView.localSegment addTarget:self action:@selector(changeLocation:) forControlEvents:UIControlEventValueChanged];
+    [_batesAddView.aligbmentSegment addTarget:self action:@selector(changeAligbment:) forControlEvents:UIControlEventValueChanged];
+    [_batesAddView.colorSlider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
+}
+
+- (void)initExtendEvent {
     [_batesAddView.pageIndexNumberText addTarget:self action:@selector(changePageStart:) forControlEvents:UIControlEventEditingChanged];
     [_batesAddView.pageNumberText addTarget:self action:@selector(changeText:) forControlEvents:UIControlEventEditingChanged];
     
@@ -132,7 +132,7 @@
 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
     self.batesAddView.fontNameText.text = [self.dataArray[indexPath.row] fontName];
     
-    self.modelBatesData.fontName = [self.dataArray[indexPath.row] fontName];
+    self.modelData.fontName = [self.dataArray[indexPath.row] fontName];
     
     self.showLabel.font = [UIFont fontWithName:[self.dataArray[indexPath.row] fontName] size:5];
 }
@@ -141,7 +141,7 @@
 
 // Done button enable
 - (void)doneBatesClick:(UIBarButtonItem *)btn {
-    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelBatesData,@"batesModel", nil];
+    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"batesModel", nil];
     NSNotification *notification = [NSNotification notificationWithName:@"getAddBatesModel" object:nil userInfo:dict];
     [[NSNotificationCenter defaultCenter] postNotification:notification];
     [self.navigationController popViewControllerAnimated:YES];
@@ -181,157 +181,22 @@
     }
     
     self.showLabel.text = showText;
-    self.modelBatesData.fontText = text.text;
+    self.modelData.fontText = text.text;
 }
 
 // Get page text start for bates's model
 - (void)changePageStart:(UITextField *)text {
     int start = [text.text intValue];
-    self.modelBatesData.pageStart = [NSString stringWithFormat:@"%d",start - 1];
+    self.modelData.pageStart = [NSString stringWithFormat:@"%d",start - 1];
 }
 
-// Slider select color
-- (void)sliderChange:(UISlider *)slider {
-    switch ((int)slider.value / 10) {
-        case 0:
-            self.showLabel.textColor = [UIColor redColor];
-            self.modelBatesData.fontColor = [UIColor redColor];
-            break;
-        case 1:
-            self.showLabel.textColor = [UIColor orangeColor];
-            self.modelBatesData.fontColor = [UIColor orangeColor];
-            break;
-        case 2:
-            self.showLabel.textColor = [UIColor colorWithRed:239.0 / 255 green:140.0 / 255 blue:133.0 / 255 alpha:1];
-            self.modelBatesData.fontColor = [UIColor colorWithRed:239.0 / 255 green:140.0 / 255 blue:133.0 / 255 alpha:1];
-            break;
-        case 3:
-            self.showLabel.textColor = [UIColor yellowColor];
-            self.modelBatesData.fontColor = [UIColor yellowColor];
-            break;
-        case 4:
-            self.showLabel.textColor = [UIColor greenColor];
-            self.modelBatesData.fontColor = [UIColor greenColor];
-            break;
-        case 5:
-            self.showLabel.textColor = [UIColor blueColor];
-            self.modelBatesData.fontColor = [UIColor blueColor];
-            break;
-        case 6:
-            self.showLabel.textColor = [UIColor purpleColor];
-            self.modelBatesData.fontColor = [UIColor purpleColor];
-            break;
-        case 7:
-            self.showLabel.textColor = [UIColor colorWithRed:235.0 / 255 green:61.0 / 255 blue:133.0 / 255 alpha:1];
-            self.modelBatesData.fontColor = [UIColor colorWithRed:235.0 / 255 green:61.0 / 255 blue:133.0 / 255 alpha:1];
-            break;
-        case 8:
-            self.showLabel.textColor = [UIColor blackColor];
-            self.modelBatesData.fontColor = [UIColor blackColor];
-            break;
-        default:
-            break;
-    }
-}
-
-// Select headerfooter
-- (void)changeLocation:(UISegmentedControl *)sender {
-    if (sender.selectedSegmentIndex == 0) {
-        _position.location = kHeader;
-    } else {
-        _position.location = kFooter;
-    }
-    [self showPages];
-}
-
-// Select aligment
-- (void)changeAligbment:(UISegmentedControl *)sender {
-    if (sender.selectedSegmentIndex == 0) {
-        _position.aligment = kLeft;
-    } else if (sender.selectedSegmentIndex == 1) {
-        _position.aligment = kCenter;
-    } else {
-        _position.aligment = kRinght;
-    }
-    [self showPages];
-}
-
-// Show headerfooter and aligment
-- (void)showPages {
-    if (_showLabel == nil) {
-        _showLabel = [[UILabel alloc] init];
-    }
-    [_showLabel setText:@"2100"];
-    _showLabel.font = [UIFont systemFontOfSize:5];
-    [self.imageView addSubview:self.showLabel];
-    
-    switch (self.position.location) {
-        case kHeader:
-            if (self.position.aligment == kLeft) {
-                [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(_imageView.mas_top).offset(1);
-                    make.left.equalTo(self.imageView.mas_left).offset(1);
-                    make.height.mas_equalTo(5);
-                    make.width.mas_equalTo(30);
-                }];
-                self.modelBatesData.fontPosition = 0;
-            } else if (self.position.aligment == kCenter) {
-                [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(_imageView.mas_top).offset(1);
-                    make.left.equalTo(self.imageView.mas_left).offset(self.size.width / 6);
-                    make.height.mas_equalTo(5);
-                    make.width.mas_equalTo(30);
-                }];
-                self.modelBatesData.fontPosition = 1;
-            } else {
-                [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(self.imageView.mas_top).offset(0.5);
-                    make.left.equalTo(self.imageView.mas_left).offset(self.size.width / 3 - 12);
-                    make.height.mas_equalTo(5);
-                    make.width.mas_equalTo(30);
-                }];
-                self.modelBatesData.fontPosition = 2;
-            }
-            break;
-            
-        case kFooter:
-            if (self.position.aligment == kLeft) {
-                [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(self.imageView.mas_top).offset(self.size.height / 3 - 12);
-                    make.left.equalTo(self.imageView.mas_left).offset(0.5);
-                    make.height.mas_equalTo(5);
-                    make.width.mas_equalTo(30);
-                }];
-                self.modelBatesData.fontPosition = 3;
-            } else if (self.position.aligment == kCenter) {
-                [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(self.imageView.mas_top).offset(self.size.height / 3 - 12);
-                    make.left.equalTo(self.imageView.mas_left).offset(self.size.width/6);
-                    make.height.mas_equalTo(5);
-                    make.width.mas_equalTo(30);
-                }];
-                self.modelBatesData.fontPosition = 4;
-            } else {
-                [_showLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
-                    make.top.equalTo(self.imageView.mas_top).offset(self.size.height / 3 - 12);
-                    make.left.equalTo(self.imageView.mas_left).offset(self.size.width / 3 - 12);
-                    make.height.mas_equalTo(5);
-                    make.width.mas_equalTo(30);
-                }];
-                self.modelBatesData.fontPosition = 5;
-            }
-            break;
-        default:
-            break;
-    }
-}
 
 #pragma mark - Orientation
 
 // When orientation
 - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
     if ([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) {
-        [_imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.view.mas_top).offset((393 / 2) - (self.size.height / 6));
             make.left.equalTo(self.view.mas_left).offset((393 / 2) - (self.size.width / 6));
             make.width.mas_equalTo(self.size.width / 3);
@@ -346,7 +211,7 @@
         }];
         
     } else if ([UIDevice currentDevice].orientation == UIDeviceOrientationPortrait) {
-        [_imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
+        [self.imageView mas_remakeConstraints:^(MASConstraintMaker *make) {
             make.top.equalTo(self.view.mas_top).offset(125);
             make.left.equalTo(self.view.mas_left).offset((393 / 2) - (self.size.width / 6));
             make.width.mas_equalTo(self.size.width / 3);

+ 10 - 4
PDFViewer/Controller/CPDFHeaderFooterAddController.h

@@ -37,16 +37,22 @@ typedef struct PositionRec {
 @interface CPDFHeaderFooterAddController : UIViewController  <UITableViewDelegate,UITableViewDataSource,UITextFieldDelegate>
 
 - (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
+- (void)initIamge;
+- (void)initNavigation;
+- (void)textFieldDidBeginEditing:(UITextField *)textField;
+- (void)cancelClick:(UIBarButtonItem *)btn;
+- (void)sliderChange:(UISlider *)slider;
+- (void)changeLocation:(UISegmentedControl *)sender;
+- (void)changeAligbment:(UISegmentedControl *)sender;
+- (void)showPages;
+- (void)initShowLabel;
  
 @property (nonatomic,assign) CGSize size;
 @property (nonatomic,strong) UIImage *image;
 @property (nonatomic,assign) PositionRec position;
-@property (nonatomic,strong) CPDFHeaderFooterAddView *headerFooterview;
 @property (nonatomic,strong) UILabel *showLabel;
-@property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
 @property (nonatomic,strong) UIImageView *imageView;
-@property (nonatomic,strong) CPDFHeaderFooterTextTableView *pageFormat;
-@property (nonatomic,strong) NSMutableArray *dataArray;
+@property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
 
 @end
 

+ 69 - 27
PDFViewer/Controller/CPDFHeaderFooterAddController.m

@@ -9,64 +9,108 @@
 
 @interface CPDFHeaderFooterAddController ()
 
+@property (nonatomic,strong) CPDFHeaderFooterAddView *headerFooterview;
+@property (nonatomic,strong) CPDFHeaderFooterTextTableView *pageFormat;
+@property (nonatomic,strong) NSMutableArray *dataArray;
+
 @end
 
 @implementation CPDFHeaderFooterAddController
 
-- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size {
-    self = [super init];
-    if (self) {
-        _image = image;
-        _size  = size;
-    }
-    return self;
-}
-
 - (void)viewDidLoad { 
     [super viewDidLoad];
     
     // Do any additional setup after loading the view.
     // Setting navigation
+    [self initNavigation];
+    
+    // Initialize show label
+    [self initShowLabel];
+    
+    // Initialize model
+    [self initModel];
+    
+    // Add page image
+    [self initIamge];
+    
+    // Add view
+    [self initBttonmView];
+
+    // UI event
+    [self initBasicEvent];
+    
+    [self initExtendEvent];
+}
+
+#pragma mark - Initializers
+
+- (void)initNavigation {
     self.navigationItem.title = @"Add Page NUmber";
     self.navigationController.toolbarHidden = YES;
     self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(doneClick:)];
     self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelClick:)];
-    
-    // Initialize model
+}
+
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size {
+    self = [super init];
+    if (self) {
+        _image = image;
+        _size  = size;
+    }
+    return self;
+}
+
+- (void)initModel {
     _modelData = [[CPDFHeaderFooterModel alloc] init];
     _modelData.fontSize = 18.0;
     _modelData.fontSelcet = 0;
     _modelData.fontPosition = 1;
     _modelData.pageStart = @"1";
-    
-    // Add page image
-    _headerFooterview = [[CPDFHeaderFooterAddView alloc] init];
+}
+
+- (void)initShowLabel {
+    _showLabel = [[UILabel alloc] init];
+    [_showLabel setText:@"1"];
+    _showLabel.font = [UIFont systemFontOfSize:6];
+}
+
+- (void)initIamge {
     _imageView = [[UIImageView alloc] init];
+    
     _imageView.image = self.image;
     CALayer *layer = [_imageView layer];
     layer.borderColor = [[UIColor blackColor] CGColor];
     layer.borderWidth = 1.0f;
     [self.view addSubview:_imageView];
-    [self.view addSubview:_headerFooterview];
+    
     [_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.view.mas_top).offset(125);
         make.left.equalTo(self.view.mas_left).offset((393 / 2) - (self.size.width / 6));
         make.width.mas_equalTo(self.size.width / 3);
         make.height.mas_equalTo(self.size.height / 3);
     }];
+}
+
+- (void)initBttonmView {
+    _headerFooterview = [[CPDFHeaderFooterAddView alloc] init];
+    [_headerFooterview setText];
+    [self.view addSubview:_headerFooterview];
     
-    // Add view
     [self.headerFooterview mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(self.imageView.mas_bottom).offset(60);
         make.left.equalTo(self.view.mas_left);
         make.width.mas_equalTo(self.view.frame.size.width);
         make.height.mas_equalTo(self.view.frame.size.height);
     }];
-    
-    // UI event
+}
+
+- (void)initBasicEvent {
     [_headerFooterview.localSegment addTarget:self action:@selector(changeLocation:) forControlEvents:UIControlEventValueChanged];
     [_headerFooterview.aligbmentSegment addTarget:self action:@selector(changeAligbment:) forControlEvents:UIControlEventValueChanged];
     [_headerFooterview.colorSlider addTarget:self action:@selector(sliderChange:) forControlEvents:UIControlEventValueChanged];
+}
+
+- (void)initExtendEvent {
     [_headerFooterview.fontSizeText addTarget:self action:@selector(changeFontSize:) forControlEvents:UIControlEventEditingChanged];
     [_headerFooterview.pageIndexNumberText addTarget:self action:@selector(changePageStart:) forControlEvents:UIControlEventEditingChanged];
     
@@ -93,7 +137,7 @@
 
 // TableView initialize
 - (void)textFieldDidBeginEditing:(UITextField *)textField {
-    _pageFormat = [[CPDFHeaderFooterTextTableView alloc] initWithTitleName:@"Page Format"];
+    _pageFormat = [[CPDFHeaderFooterTextTableView alloc] initWithTitleName:@"Format Selection"];
     
     _pageFormat.tableView.delegate = self;
     _pageFormat.tableView.dataSource = self;
@@ -257,8 +301,6 @@
     if (_showLabel == nil) {
         _showLabel = [[UILabel alloc] init];
     }
-    [_showLabel setText:@"1"];
-    _showLabel.font = [UIFont systemFontOfSize:6];
     [self.imageView addSubview:self.showLabel];
     
     switch (self.position.location) {
@@ -268,7 +310,7 @@
                     make.top.equalTo(_imageView.mas_top).offset(0.5);
                     make.left.equalTo(self.imageView.mas_left).offset(0.5);
                     make.height.mas_equalTo(10);
-                    make.width.mas_equalTo(10);
+                    make.width.mas_equalTo(20);
                 }];
                 self.modelData.fontPosition = 0;
             } else if (self.position.aligment == kCenter) {
@@ -276,7 +318,7 @@
                     make.top.equalTo(_imageView.mas_top).offset(0.5);
                     make.left.equalTo(self.imageView.mas_left).offset(self.size.width / 6);
                     make.height.mas_equalTo(10);
-                    make.width.mas_equalTo(10);
+                    make.width.mas_equalTo(20);
                 }];
                 self.modelData.fontPosition = 1;
             } else {
@@ -284,7 +326,7 @@
                     make.top.equalTo(self.imageView.mas_top).offset(0.5);
                     make.left.equalTo(self.imageView.mas_left).offset(self.size.width / 3 - 12);
                     make.height.mas_equalTo(10);
-                    make.width.mas_equalTo(10);
+                    make.width.mas_equalTo(20);
                 }];
                 self.modelData.fontPosition = 2;
             }
@@ -296,7 +338,7 @@
                     make.top.equalTo(self.imageView.mas_top).offset(self.size.height / 3 - 12);
                     make.left.equalTo(self.imageView.mas_left).offset(0.5);
                     make.height.mas_equalTo(10);
-                    make.width.mas_equalTo(10);
+                    make.width.mas_equalTo(20);
                 }];
                 self.modelData.fontPosition = 3;
             } else if (self.position.aligment == kCenter) {
@@ -304,7 +346,7 @@
                     make.top.equalTo(self.imageView.mas_top).offset(self.size.height / 3 - 12);
                     make.left.equalTo(self.imageView.mas_left).offset(self.size.width/6);
                     make.height.mas_equalTo(10);
-                    make.width.mas_equalTo(10);
+                    make.width.mas_equalTo(20);
                 }];
                 self.modelData.fontPosition = 4;
             } else {
@@ -312,7 +354,7 @@
                     make.top.equalTo(self.imageView.mas_top).offset(self.size.height / 3 - 12);
                     make.left.equalTo(self.imageView.mas_left).offset(self.size.width / 3 - 12);
                     make.height.mas_equalTo(10);
-                    make.width.mas_equalTo(10);
+                    make.width.mas_equalTo(20);
                 }];
                 self.modelData.fontPosition = 5;
             }

+ 4 - 8
PDFViewer/Controller/CPDFHeaderFooterAddView.h

@@ -6,20 +6,14 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "CPDFAddView.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
 #define kNumber @"^[0-9]+$";
 
-@interface CPDFHeaderFooterAddView : UIView  <UITextFieldDelegate>
+@interface CPDFHeaderFooterAddView : CPDFAddView  <UITextFieldDelegate>
 
-@property (nonatomic,strong) UILabel *localLabel;
-@property (nonatomic,strong) UISegmentedControl *localSegment;
-@property (nonatomic,strong) UILabel *alignmentLabel;
-@property (nonatomic,strong) UISegmentedControl *aligbmentSegment;
-@property (nonatomic,strong) UILabel *colorLabel;
-@property (nonatomic,strong) UIImageView *colerImage;
-@property (nonatomic,strong) UISlider *colorSlider;
 @property (nonatomic,strong) UILabel *pageNumberLabel;
 @property (nonatomic,strong) UITextField *pageNumberText;
 @property (nonatomic,strong) UILabel *fontSizeLabel;
@@ -28,6 +22,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,strong) UITextField *pageIndexNumberText;
 @property (nonatomic,strong) UIStepper *pageIndexNumberStepper;
 
+- (void)setText;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 101 - 129
PDFViewer/Controller/CPDFHeaderFooterAddView.m

@@ -12,157 +12,129 @@
 
 - (instancetype)initWithFrame:(CGRect)frame {
     self = [super initWithFrame:frame];
-    CGFloat offsetx = 3.5;
     if (self) {
-        // Page number location
-        _localLabel = [[UILabel alloc] init];
-        [_localLabel setText:@"Page number position"];
-        _localLabel.font = [UIFont boldSystemFontOfSize:12];
-        NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
-        _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
-        [self addSubview:_localLabel];
-        [self addSubview:_localSegment];
-        [_localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.mas_top).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.width.mas_equalTo(130);
-            make.height.mas_equalTo(22);
-        }];
-        [_localSegment mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_localLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        
-        // Alignment
-        _alignmentLabel = [[UILabel alloc] init];
-        [_alignmentLabel setText:@"alignment"];
-        _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
-        NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
-        _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
-        [self addSubview:_alignmentLabel];
-        [self addSubview:_aligbmentSegment];
-        [_alignmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_localSegment.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.width.mas_equalTo(100);
-            make.height.mas_equalTo(22);
-        }];
-        [_aligbmentSegment mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_alignmentLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        
-        // Font color
-        _colorLabel = [[UILabel alloc] init];
-        [_colorLabel setText:@"Font Color"];
-        _colorLabel.font = [UIFont boldSystemFontOfSize:12];
-        _colerImage = [[UIImageView alloc] init];
-        CALayer *layer = [_colerImage layer];
-        layer.borderColor = [[UIColor blackColor] CGColor];
-        layer.borderWidth = 0.5f;
-        _colerImage.image = [UIImage imageNamed:@"text_color_bar"];
-        _colorSlider = [[UISlider alloc] init];
-        _colorSlider.minimumValue = 0;
-        _colorSlider.maximumValue = 100;
-        _colorSlider.value = 5;
-        [self addSubview:_colorLabel];
-        [self addSubview:_colorSlider];
-        [self addSubview:_colerImage];
-        [_colorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_aligbmentSegment.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.width.mas_equalTo(100);
-            make.height.mas_equalTo(22);
-        }];
-        [_colerImage mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        [_colorSlider mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colerImage.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        
         // Page number
         _pageNumberLabel = [[UILabel alloc] init];
-        [_pageNumberLabel setText:@"Page Text"];
-        _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
         _pageNumberText = [[UITextField alloc] init];
-        _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
-        _pageNumberText.placeholder = @"text";
+        
         [self addSubview:_pageNumberLabel];
         [self addSubview:_pageNumberText];
-        [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(73);
-        }];
-        [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(93);
-        }];
         
         // Font size
         _fontSizeLabel = [[UILabel alloc] init];
-        [_fontSizeLabel setText:@"Font Szie"];
-        _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
         _fontSizeText = [[UITextField alloc] init];
-        _fontSizeText.borderStyle = UITextBorderStyleRoundedRect;
-        _fontSizeText.placeholder = @"18.0";
-        _fontSizeText.keyboardType = UIKeyboardTypeDefault;
-        _fontSizeText.delegate = self;
+        
         [self addSubview:_fontSizeLabel];
         [self addSubview:_fontSizeText];
-        [_fontSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(_pageNumberText.mas_right).offset(offsetx + 20);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(73);
-        }];
-        [_fontSizeText mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(_fontSizeLabel.mas_right).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(93);
-        }];
         
-        // Font index
+        // Page index
         _pageIndexLabel = [[UILabel alloc] init];
-        [_pageIndexLabel setText:@"Page Start"];
-        _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
         _pageIndexNumberText = [[UITextField alloc] init];
-        _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
-        _pageIndexNumberText.placeholder = @"1";
+        
         [self addSubview:_pageIndexLabel];
         [self addSubview:_pageIndexNumberText];
-        [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_pageNumberLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(73);
-        }];
-        [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_pageNumberText.mas_bottom).offset(offsetx+5);
-            make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
-            make.height.mas_equalTo(33);
-            make.width.mas_equalTo(93);
-        }];
+        
         self.backgroundColor = [UIColor whiteColor];
     }
     return  self;
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    CGFloat offsetx = 3.5;
+    
+    // Page number
+    [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(73);
+    }];
+    
+    [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(93);
+    }];
+    
+    // Font size
+    [_fontSizeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(_pageNumberText.mas_right).offset(offsetx + 20);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(73);
+    }];
+    
+    [_fontSizeText mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(_fontSizeLabel.mas_right).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(93);
+    }];
+    
+    // Page index
+    [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_pageNumberLabel.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(73);
+    }];
+    
+    [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_pageNumberText.mas_bottom).offset(offsetx+5);
+        make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
+        make.height.mas_equalTo(33);
+        make.width.mas_equalTo(93);
+    }];
+}
+
+- (void)setText {
+    // Page number location
+    [self.localLabel setText:@"Page number position"];
+    self.localLabel.font = [UIFont boldSystemFontOfSize:12];
+    
+    // Alignment
+    [self.alignmentLabel setText:@"alignment"];
+    self.alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
+    
+    // Font color
+    [self.colorLabel setText:@"Font Color"];
+    self.colorLabel.font = [UIFont boldSystemFontOfSize:12];
+    
+    CALayer *layer = [self.colerImage layer];
+    layer.borderColor = [[UIColor blackColor] CGColor];
+    layer.borderWidth = 0.5f;
+    self.colerImage.image = [UIImage imageNamed:@"text_color_bar"];
+    
+    self.colorSlider.minimumValue = 0;
+    self.colorSlider.maximumValue = 100;
+    self.colorSlider.value = 5;
+    
+    // Page number
+    [_pageNumberLabel setText:@"Page Text"];
+    _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
+    
+    _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
+    _pageNumberText.placeholder = @"text";
+    
+    // Font size
+    [_fontSizeLabel setText:@"Font Szie"];
+    _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
+    
+    _fontSizeText.borderStyle = UITextBorderStyleRoundedRect;
+    _fontSizeText.placeholder = @"18.0";
+    _fontSizeText.delegate = self;
+    _fontSizeText.keyboardType = UIKeyboardTypeDefault;
+    
+    // Page index
+    [_pageIndexLabel setText:@"Page Start"];
+    _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
+    
+    _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
+    _pageIndexNumberText.placeholder = @"1";
+}
+
 #pragma mark - UITextFieldDelegate
 
 - (BOOL)textFieldShouldReturn:(UITextField *)textField {

+ 5 - 0
PDFViewer/Controller/CPDFHeaderFooterDeleteController.m

@@ -18,16 +18,21 @@
 - (void)viewDidLoad {
     [super viewDidLoad];
     UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete Page Number" message:@"Are you sure delete all pages number" preferredStyle:UIAlertControllerStyleAlert];
+    
     UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
         NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:@"1",@"delete", nil];
         NSNotification *notification = [NSNotification notificationWithName:@"deleteHeaderFooter" object:nil userInfo:dict];
+        
         [[NSNotificationCenter defaultCenter] postNotification:notification];
         }];
+    
     UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
         NSLog(@"Cancel Action");
         }];
+    
     [alertController addAction:okAction];
     [alertController addAction:cancelAction];
+    
     [self presentViewController:alertController animated:YES completion:nil];
 }
 

+ 78 - 72
PDFViewer/Controller/CPDFViewController.m

@@ -12,7 +12,6 @@
 #import "CPDFHeaderFooterDeleteController.h"
 #import "CPDFBatesDeleteViewController.h"
 #import "CPDFBatesAddViewController.h"
-#import "CPDFBatesModel.h"
 
 @interface CPDFViewController () <UIActionSheetDelegate>
 
@@ -20,8 +19,6 @@
 @property (nonatomic,assign) CGSize size;
 @property (nonatomic,strong) CPDFDocument *document;
 @property (nonatomic,strong) CPDFView *pdfView;
-@property (nonatomic,strong) CPDFHeaderFooterModel *modelData;
-@property (nonatomic,strong) CPDFBatesModel *modelBatesData;
 
 @end
 
@@ -76,62 +73,12 @@
     
     // Setting headerfooter action
     UIAlertAction *settingHeaderFooter = [UIAlertAction actionWithTitle:@"Setting Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        
-        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-        
-        // Add headerfooter action
-        UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            CPDFHeaderFooterAddController *headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size];
-            
-            [self.navigationController pushViewController:headerFooterControl animated:NO];
-            }];
-        
-        // Delete headerfooter action
-        UIAlertAction *deleteHeaderfooterAction = [UIAlertAction actionWithTitle:@"Delete Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            CPDFHeaderFooterDeleteController *headerFooterDeleteControl = [[CPDFHeaderFooterDeleteController alloc] init];
-            
-            [self addChildViewController:headerFooterDeleteControl];
-            [self.view addSubview:headerFooterDeleteControl.view];
-            }];
-        
-        // Cancel Action
-        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-                NSLog(@"Cancel Action");
-            }];
-        
-        [alertController addAction:addHeaderfooterAction];
-        [alertController addAction:deleteHeaderfooterAction];
-        [alertController addAction:cancelAction];
-        
-        [self presentViewController:alertController animated:YES completion:nil];
+        [self settingHeaterFooterAction];
        }];
     
     // Seeting bates action
     UIAlertAction *settingBatesAction = [UIAlertAction actionWithTitle:@"Setting Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
-        
-        UIAlertAction *addBatesAction = [UIAlertAction actionWithTitle:@"Add Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            CPDFBatesAddViewController *batesAddControl = [[CPDFBatesAddViewController alloc] initWithIamge:self.image WithSize:self.size];
-            
-            [self.navigationController pushViewController:batesAddControl animated:NO];
-            }];
-        
-        UIAlertAction *delereBatesAction = [UIAlertAction actionWithTitle:@"Delete Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-            CPDFBatesDeleteViewController *batesDeleteControl = [[CPDFBatesDeleteViewController alloc] init];
-            
-            [self addChildViewController:batesDeleteControl];
-            [self.view addSubview:batesDeleteControl.view];
-            }];
-        
-        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
-                NSLog(@"Cancel Action");
-            }];
-        
-        [alertController addAction:addBatesAction];
-        [alertController addAction:delereBatesAction];
-        [alertController addAction:cancelAction];
-        
-        [self presentViewController:alertController animated:YES completion:nil];
+        [self settingBatesAction];
        }];
     
     // Cancel action
@@ -148,40 +95,99 @@
     [self presentViewController:alertController animated:YES completion:nil];
 }
 
+// Setting headerfooter action
+- (void)settingHeaterFooterAction {
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    
+    // Add headerfooter action
+    UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        CPDFHeaderFooterAddController *headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size];
+        
+        [self.navigationController pushViewController:headerFooterControl animated:NO];
+        }];
+    
+    // Delete headerfooter action
+    UIAlertAction *deleteHeaderfooterAction = [UIAlertAction actionWithTitle:@"Delete Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        CPDFHeaderFooterDeleteController *headerFooterDeleteControl = [[CPDFHeaderFooterDeleteController alloc] init];
+        
+        [self addChildViewController:headerFooterDeleteControl];
+        [self.view addSubview:headerFooterDeleteControl.view];
+        }];
+    
+    // Cancel Action
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+            NSLog(@"Cancel Action");
+        }];
+    
+    [alertController addAction:addHeaderfooterAction];
+    [alertController addAction:deleteHeaderfooterAction];
+    [alertController addAction:cancelAction];
+    
+    [self presentViewController:alertController animated:YES completion:nil];
+}
+
+// Seeting bates action
+- (void)settingBatesAction {
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    
+    UIAlertAction *addBatesAction = [UIAlertAction actionWithTitle:@"Add Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        CPDFBatesAddViewController *batesAddControl = [[CPDFBatesAddViewController alloc] initWithIamge:self.image WithSize:self.size];
+        
+        [self.navigationController pushViewController:batesAddControl animated:NO];
+        }];
+    
+    UIAlertAction *delereBatesAction = [UIAlertAction actionWithTitle:@"Delete Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        CPDFBatesDeleteViewController *batesDeleteControl = [[CPDFBatesDeleteViewController alloc] init];
+        
+        [self addChildViewController:batesDeleteControl];
+        [self.view addSubview:batesDeleteControl.view];
+        }];
+    
+    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
+            NSLog(@"Cancel Action");
+        }];
+    
+    [alertController addAction:addBatesAction];
+    [alertController addAction:delereBatesAction];
+    [alertController addAction:cancelAction];
+    
+    [self presentViewController:alertController animated:YES completion:nil];
+}
+
 #pragma mark - Function
 
 // Get headerfooter' model to setting page headerfooter's add functional property
 - (void)getHeaderFooterModel:(NSNotification *)addSign {
-    _modelData = addSign.userInfo[@"model"];
+    CPDFHeaderFooterModel *modelData = addSign.userInfo[@"model"];
     CPDFHeaderFooter *headerFooter = [self.document headerFooter];
     
     NSString *pageIndex = [NSString stringWithFormat:@"0-%lu",self.document.pageCount - 1];
     NSString *text = [[NSString alloc] init];
     
-    switch (_modelData.fontSelcet) {
+    switch (modelData.fontSelcet) {
         case 0:
-            text = [NSString stringWithFormat:@"<<%@>>",self.modelData.pageStart];
+            text = [NSString stringWithFormat:@"<<%@>>",modelData.pageStart];
             break;
         case 1:
-            text = [NSString stringWithFormat:@"page <<%@>>",self.modelData.pageStart];
+            text = [NSString stringWithFormat:@"page <<%@>>",modelData.pageStart];
             break;
         case 2:
-            text = [NSString stringWithFormat:@"<<%@>>/%lu",self.modelData.pageStart,self.document.pageCount];
+            text = [NSString stringWithFormat:@"<<%@>>/%lu",modelData.pageStart,self.document.pageCount];
             break;
         case 3:
-            text = [NSString stringWithFormat:@"<<%@>> of %lu",self.modelData.pageStart,self.document.pageCount];
+            text = [NSString stringWithFormat:@"<<%@>> of %lu",modelData.pageStart,self.document.pageCount];
             break;
         case 4:
-            text = [NSString stringWithFormat:@"page <<%@>> of %lu",self.modelData.pageStart,self.document.pageCount];
+            text = [NSString stringWithFormat:@"page <<%@>> of %lu",modelData.pageStart,self.document.pageCount];
             break;
         default:
             break;
     }
     
     headerFooter.pageString = pageIndex;
-    [headerFooter setText:text atIndex:self.modelData.fontPosition];
-    [headerFooter setFontSize:self.modelData.fontSize atIndex:self.modelData.fontPosition];
-    [headerFooter setTextColor:self.modelData.fontColor atIndex:self.modelData.fontPosition];
+    [headerFooter setText:text atIndex:modelData.fontPosition];
+    [headerFooter setFontSize:modelData.fontSize atIndex:modelData.fontPosition];
+    [headerFooter setTextColor:modelData.fontColor atIndex:modelData.fontPosition];
     [headerFooter update];
     
     NSURL *url = [NSURL fileURLWithPath:self.path];
@@ -196,16 +202,16 @@
 
 // Get bates' model to setting page bates's add functional property
 - (void)getBatesMdel:(NSNotification *)addBatesSign {
-    _modelBatesData = addBatesSign.userInfo[@"batesModel"];
+    CPDFHeaderFooterModel *modelBatesData = addBatesSign.userInfo[@"batesModel"];
     CPDFBates *bates = [self.document bates];
     
-    NSString *pageIndex = [NSString stringWithFormat:@"%@-%lu",self.modelBatesData.pageStart,self.document.pageCount - 1];
+    NSString *pageIndex = [NSString stringWithFormat:@"%@-%lu",modelBatesData.pageStart,self.document.pageCount - 1];
     bates.pageString = pageIndex;
-    NSString *text = [NSString stringWithFormat:@"<<%@>>",self.modelBatesData.fontText];
-    [bates setText:text atIndex:self.modelBatesData.fontPosition];
-    [bates setFontName:self.modelBatesData.fontName atIndex:self.modelBatesData.fontPosition];
-    [bates setFontSize:15.0 atIndex:self.modelBatesData.fontPosition];
-    [bates setTextColor:self.modelBatesData.fontColor atIndex:self.modelBatesData.fontPosition];
+    NSString *text = [NSString stringWithFormat:@"<<%@>>",modelBatesData.fontText];
+    [bates setText:text atIndex:modelBatesData.fontPosition];
+    [bates setFontName:modelBatesData.fontName atIndex:modelBatesData.fontPosition];
+    [bates setFontSize:15.0 atIndex:modelBatesData.fontPosition];
+    [bates setTextColor:modelBatesData.fontColor atIndex:modelBatesData.fontPosition];
     [bates update];
     
     NSURL *url = [NSURL fileURLWithPath:self.path];

+ 0 - 24
PDFViewer/Controller/Model/CPDFBatesModel.h

@@ -1,24 +0,0 @@
-//
-//  CPDFBatesModel.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/24.
-//
-
-#import <Foundation/Foundation.h>
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface CPDFBatesModel : NSObject
-
-@property (nonatomic,strong) UIColor *fontColor;
-@property (nonatomic,assign) NSUInteger fontPosition;
-@property (nonatomic,strong) NSString *fontText;
-@property (nonatomic,strong) NSString *pageStart;
-@property (nonatomic,strong) NSString *fontName;
-@property (nonatomic,assign) CGFloat fontSize;
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 12
PDFViewer/Controller/Model/CPDFBatesModel.m

@@ -1,12 +0,0 @@
-//
-//  CPDFBatesModel.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/24.
-//
-
-#import "CPDFBatesModel.h"
-
-@implementation CPDFBatesModel
-
-@end

+ 2 - 0
PDFViewer/Controller/Model/CPDFHeaderFooterModel.h

@@ -17,6 +17,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,assign) CGFloat fontSize;
 @property (nonatomic,assign) NSInteger fontSelcet;
 @property (nonatomic,strong) NSString *pageStart;
+@property (nonatomic,strong) NSString *fontName;
+@property (nonatomic,strong) NSString *fontText;
 
 @end
 

+ 24 - 0
PDFViewer/View/CPDFAddView.h

@@ -0,0 +1,24 @@
+//
+//  CPDFAddView.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/12/5.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFAddView : UIView
+
+@property (nonatomic,strong) UILabel *localLabel;
+@property (nonatomic,strong) UISegmentedControl *localSegment;
+@property (nonatomic,strong) UILabel *alignmentLabel;
+@property (nonatomic,strong) UISegmentedControl *aligbmentSegment;
+@property (nonatomic,strong) UILabel *colorLabel;
+@property (nonatomic,strong) UIImageView *colerImage;
+@property (nonatomic,strong) UISlider *colorSlider;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 100 - 0
PDFViewer/View/CPDFAddView.m

@@ -0,0 +1,100 @@
+//
+//  CPDFAddView.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/12/5.
+//
+
+#import "CPDFAddView.h"
+#import "Masonry.h"
+
+@implementation CPDFAddView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    self = [super initWithFrame:frame];
+    if (self) {
+        _localLabel = [[UILabel alloc] init];
+        NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
+        _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
+        
+        [self addSubview:_localLabel];
+        [self addSubview:_localSegment];
+        
+        // Alignment
+        _alignmentLabel = [[UILabel alloc] init];
+        NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
+        _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
+        
+        [self addSubview:_alignmentLabel];
+        [self addSubview:_aligbmentSegment];
+        
+        // Font color
+        _colorLabel = [[UILabel alloc] init];
+        _colerImage = [[UIImageView alloc] init];
+        _colorSlider = [[UISlider alloc] init];
+        
+        [self addSubview:_colorLabel];
+        [self addSubview:_colorSlider];
+        [self addSubview:_colerImage];
+    }
+    return self;
+}
+
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    CGFloat offsetx = 3.5;
+    
+    // Page number location
+    [_localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.mas_top).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.width.mas_equalTo(130);
+        make.height.mas_equalTo(22);
+    }];
+    
+    [_localSegment mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_localLabel.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(4 * offsetx);
+        make.width.mas_equalTo(364);
+        make.height.mas_equalTo(44);
+    }];
+    
+    // Alignment
+    [_alignmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_localSegment.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.width.mas_equalTo(100);
+        make.height.mas_equalTo(22);
+    }];
+    
+    [_aligbmentSegment mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_alignmentLabel.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(4 * offsetx);
+        make.width.mas_equalTo(364);
+        make.height.mas_equalTo(44);
+    }];
+    
+    // Font color
+    [_colorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_aligbmentSegment.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.width.mas_equalTo(100);
+        make.height.mas_equalTo(22);
+    }];
+    
+    [_colerImage mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_colorLabel.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(4 * offsetx);
+        make.width.mas_equalTo(364);
+        make.height.mas_equalTo(44);
+    }];
+    
+    [_colorSlider mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_colerImage.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(4 * offsetx);
+        make.width.mas_equalTo(364);
+        make.height.mas_equalTo(44);
+    }];
+}
+
+@end

+ 4 - 8
PDFViewer/View/CPDFBatesAddView.h

@@ -6,18 +6,12 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "CPDFAddView.h"
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface CPDFBatesAddView : UIView <UITextFieldDelegate>
+@interface CPDFBatesAddView : CPDFAddView <UITextFieldDelegate>
 
-@property (nonatomic,strong) UILabel *localLabel;
-@property (nonatomic,strong) UISegmentedControl *localSegment;
-@property (nonatomic,strong) UILabel *alignmentLabel;
-@property (nonatomic,strong) UISegmentedControl *aligbmentSegment;
-@property (nonatomic,strong) UILabel *colorLabel;
-@property (nonatomic,strong) UIImageView *colerImage;
-@property (nonatomic,strong) UISlider *colorSlider;
 @property (nonatomic,strong) UILabel *pageNumberLabel;
 @property (nonatomic,strong) UITextField *pageNumberText;
 @property (nonatomic,strong) UILabel *fontNameLabel;
@@ -26,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,strong) UITextField *pageIndexNumberText;
 @property (nonatomic,strong) UIStepper *pageIndexNumberStepper;
 
+- (void)setText;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 99 - 128
PDFViewer/View/CPDFBatesAddView.m

@@ -12,155 +12,126 @@
 
 - (instancetype)initWithFrame:(CGRect)frame {
     self = [super initWithFrame:frame];
-    CGFloat offsetx = 3.5;
     if (self) {
-        // Page number location
-        _localLabel = [[UILabel alloc] init];
-        [_localLabel setText:@"Page number position"];
-        _localLabel.font = [UIFont boldSystemFontOfSize:12];
-        NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
-        _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
-        [self addSubview:_localLabel];
-        [self addSubview:_localSegment];
-        [_localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.mas_top).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.width.mas_equalTo(130);
-            make.height.mas_equalTo(22);
-        }];
-        [_localSegment mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_localLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        
-        // Alignment
-        _alignmentLabel = [[UILabel alloc] init];
-        [_alignmentLabel setText:@"alignment"];
-        _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
-        NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
-        _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
-        [self addSubview:_alignmentLabel];
-        [self addSubview:_aligbmentSegment];
-        [_alignmentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_localSegment.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.width.mas_equalTo(100);
-            make.height.mas_equalTo(22);
-        }];
-        [_aligbmentSegment mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_alignmentLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        
-        // Font color
-        _colorLabel = [[UILabel alloc] init];
-        [_colorLabel setText:@"Font Color"];
-        _colorLabel.font = [UIFont boldSystemFontOfSize:12];
-        _colerImage = [[UIImageView alloc] init];
-        CALayer *layer = [_colerImage layer];
-        layer.borderColor = [[UIColor blackColor] CGColor];
-        layer.borderWidth = 0.5f;
-        _colerImage.image = [UIImage imageNamed:@"text_color_bar"];
-        _colorSlider = [[UISlider alloc] init];
-        _colorSlider.minimumValue = 0;
-        _colorSlider.maximumValue = 100;
-        _colorSlider.value = 5;
-        [self addSubview:_colorLabel];
-        [self addSubview:_colorSlider];
-        [self addSubview:_colerImage];
-        [_colorLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_aligbmentSegment.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.width.mas_equalTo(100);
-            make.height.mas_equalTo(22);
-        }];
-        [_colerImage mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        [_colorSlider mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colerImage.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(4 * offsetx);
-            make.width.mas_equalTo(364);
-            make.height.mas_equalTo(44);
-        }];
-        
         // Font index
         _pageIndexLabel = [[UILabel alloc] init];
-        [_pageIndexLabel setText:@"Start Page"];
-        _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
         _pageIndexNumberText = [[UITextField alloc] init];
-        _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
-        _pageIndexNumberText.placeholder = @"1";
+        
         [self addSubview:_pageIndexLabel];
         [self addSubview:_pageIndexNumberText];
-        [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(73);
-        }];
-        [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(93);
-        }];
         
         // Font Name
         _fontNameLabel = [[UILabel alloc] init];
-        [_fontNameLabel setText:@"Font Name"];
-        _fontNameLabel.font = [UIFont boldSystemFontOfSize:14];
         _fontNameText = [[UITextField alloc] init];
-        _fontNameText.borderStyle = UITextBorderStyleRoundedRect;
-        _fontNameText.placeholder = @"Helvetica";
-        _fontNameText.keyboardType = UIKeyboardTypeDefault;
-        _fontNameText.delegate = self;
+        
         [self addSubview:_fontNameLabel];
         [self addSubview:_fontNameText];
-        [_fontNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(_pageIndexNumberText.mas_right).offset(offsetx + 20);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(73);
-        }];
-        [_fontNameText mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_colorSlider.mas_bottom).offset(offsetx);
-            make.left.equalTo(_fontNameLabel.mas_right).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(93);
-        }];
         
         // Page number
         _pageNumberLabel = [[UILabel alloc] init];
-        [_pageNumberLabel setText:@"Page Text"];
-        _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
         _pageNumberText = [[UITextField alloc] init];
-        _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
-        _pageNumberText.placeholder = @"#2#1#0#0";
+        
         [self addSubview:_pageNumberLabel];
         [self addSubview:_pageNumberText];
-        [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_pageIndexLabel.mas_bottom).offset(offsetx);
-            make.left.equalTo(self.mas_left).offset(offsetx);
-            make.height.mas_equalTo(44);
-            make.width.mas_equalTo(73);
-        }];
-        [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(_pageIndexNumberText.mas_bottom).offset(offsetx+5);
-            make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
-            make.height.mas_equalTo(33);
-            make.width.mas_equalTo(153);
-        }];
+        
         self.backgroundColor = [UIColor whiteColor];
     }
     return  self;
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    CGFloat offsetx = 3.5;
+    
+    // Font index
+    [_pageIndexLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(73);
+    }];
+    [_pageIndexNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(_pageIndexLabel.mas_right).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(93);
+    }];
+    
+    // Font Name
+    [_fontNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(_pageIndexNumberText.mas_right).offset(offsetx + 20);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(73);
+    }];
+    [_fontNameText mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.colorSlider.mas_bottom).offset(offsetx);
+        make.left.equalTo(_fontNameLabel.mas_right).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(93);
+    }];
+    
+    // Page number
+    [_pageNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_pageIndexLabel.mas_bottom).offset(offsetx);
+        make.left.equalTo(self.mas_left).offset(offsetx);
+        make.height.mas_equalTo(44);
+        make.width.mas_equalTo(73);
+    }];
+    [_pageNumberText mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(_pageIndexNumberText.mas_bottom).offset(offsetx+5);
+        make.left.equalTo(_pageNumberLabel.mas_right).offset(offsetx);
+        make.height.mas_equalTo(33);
+        make.width.mas_equalTo(153);
+    }];
+}
+
+- (void)setText {
+    // Page number location
+    [self.localLabel setText:@"Page number position"];
+    self.localLabel.font = [UIFont boldSystemFontOfSize:12];
+    
+    // Alignment
+    [self.alignmentLabel setText:@"alignment"];
+    self.alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
+    
+    // Font color
+    [self.colorLabel setText:@"Font Color"];
+    self.colorLabel.font = [UIFont boldSystemFontOfSize:12];
+    
+    CALayer *layer = [self.colerImage layer];
+    layer.borderColor = [[UIColor blackColor] CGColor];
+    layer.borderWidth = 0.5f;
+    self.colerImage.image = [UIImage imageNamed:@"text_color_bar"];
+    
+    self.colorSlider.minimumValue = 0;
+    self.colorSlider.maximumValue = 100;
+    self.colorSlider.value = 5;
+    
+    // Font index
+    [_pageIndexLabel setText:@"Start Page"];
+    _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
+    
+    _pageIndexNumberText.borderStyle = UITextBorderStyleRoundedRect;
+    _pageIndexNumberText.placeholder = @"1";
+    
+    // Font Name
+    [_fontNameLabel setText:@"Font Name"];
+    _fontNameLabel.font = [UIFont boldSystemFontOfSize:14];
+    
+    _fontNameText.borderStyle = UITextBorderStyleRoundedRect;
+    _fontNameText.placeholder = @"Helvetica";
+    _fontNameText.keyboardType = UIKeyboardTypeDefault;
+    _fontNameText.delegate = self;
+    
+    // Page number
+    [_pageNumberLabel setText:@"Page Text"];
+    _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
+    
+    _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
+    _pageNumberText.placeholder = @"#2#1#0#0";
+
+}
+
+
 @end

+ 0 - 1
PDFViewer/View/CPDFHeaderFooterTextTableView.h

@@ -15,7 +15,6 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic,strong) UITableView *tableView;
 @property (nonatomic,strong) UILabel *titleView;
 @property (nonatomic,strong) UIButton *okBtn;
-@property (nonatomic,strong) UIButton *cancelBtn;
 @property (nonatomic,strong) UIView * bottomView;
 @property (nonatomic,strong) UIControl *coverView;
 

+ 39 - 38
PDFViewer/View/CPDFHeaderFooterTextTableView.m

@@ -12,15 +12,10 @@
 - (instancetype)initWithTitleName:(NSString *)titleName {
     self = [super init];
     if (self) {
+        // Tableview
         _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
         _tableView.rowHeight = 33;
         [self addSubview:_tableView];
-        [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.mas_top).offset(33);
-            make.left.equalTo(self.mas_left);
-            make.right.equalTo(self.mas_right);
-            make.bottom.equalTo(self.mas_bottom).offset(-44);
-        }];
         
         // Title
         _titleView = [[UILabel alloc] init];
@@ -31,51 +26,57 @@
         _titleView.textAlignment = NSTextAlignmentCenter;
         _titleView.textColor = [UIColor whiteColor];
         [self addSubview:_titleView];
-        [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.mas_top);
-            make.left.equalTo(self.mas_left);
-            make.right.equalTo(self.mas_right);
-            make.height.mas_equalTo(33);
-        }];
+       
         
         // View button at the bottom
         _bottomView = [[UIView alloc] init];
         _bottomView.backgroundColor = [UIColor systemGray5Color];
         [self addSubview:_bottomView];
-        [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.tableView.mas_bottom);
-            make.left.equalTo(self.mas_left);
-            make.right.equalTo(self.mas_right);
-            make.height.mas_equalTo(44);
-        }];
         
         // OK
         _okBtn = [[UIButton alloc] init];
         [_okBtn setTitle:@"OK" forState:UIControlStateNormal];
         _okBtn.titleLabel.font = [UIFont systemFontOfSize:12];
         _okBtn.backgroundColor = [UIColor systemGray3Color];
-        [self.bottomView addSubview:_okBtn];
-        [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.bottomView.mas_top).offset(6);
-            make.right.equalTo(self.bottomView.mas_right).offset(-60);
-            make.height.mas_equalTo(33);
-            make.width.mas_equalTo(40);
-        }];
-        
-        // Cancel
-        _cancelBtn = [[UIButton alloc] initWithFrame:CGRectZero];
-        [_cancelBtn setTitle:@"Cancel" forState:UIControlStateNormal];
-        _cancelBtn.titleLabel.font = [UIFont systemFontOfSize:12];
-        _cancelBtn.backgroundColor = [UIColor systemGray3Color];
-        [self.bottomView addSubview:_cancelBtn];
-        [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
-            make.top.equalTo(self.bottomView.mas_top).offset(6);
-            make.right.equalTo(self.bottomView.mas_right).offset(-10);
-            make.height.mas_equalTo(33);
-            make.width.mas_equalTo(40);
-        }];
     }
     return self;
 }
 
+- (void)layoutSubviews {
+    [super layoutSubviews];
+    
+    // Tableview
+    [self.tableView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.mas_top).offset(33);
+        make.left.equalTo(self.mas_left);
+        make.right.equalTo(self.mas_right);
+        make.bottom.equalTo(self.mas_bottom).offset(-44);
+    }];
+    
+    // Title
+    [self.titleView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.mas_top);
+        make.left.equalTo(self.mas_left);
+        make.right.equalTo(self.mas_right);
+        make.height.mas_equalTo(33);
+    }];
+    
+    // View button at the bottom
+    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.tableView.mas_bottom);
+        make.left.equalTo(self.mas_left);
+        make.right.equalTo(self.mas_right);
+        make.height.mas_equalTo(44);
+    }];
+    
+    // OK
+    [self.bottomView addSubview:_okBtn];
+    [self.okBtn mas_makeConstraints:^(MASConstraintMaker *make) {
+        make.top.equalTo(self.bottomView.mas_top).offset(6);
+        make.right.equalTo(self.bottomView.mas_right).offset(-60);
+        make.height.mas_equalTo(33);
+        make.width.mas_equalTo(40);
+    }];
+}
+
 @end