Browse Source

PDFView(ios) - 页眉页脚文本和颜色交互

yangliuhua 2 years ago
parent
commit
3335845f88
64 changed files with 4300 additions and 290 deletions
  1. 85 0
      PDFViewer.xcodeproj/project.pbxproj
  2. BIN
      PDFViewer.xcodeproj/project.xcworkspace/xcuserdata/kdanmobile_2.xcuserdatad/UserInterfaceState.xcuserstate
  3. 104 0
      PDFViewer.xcodeproj/xcuserdata/kdanmobile_2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
  4. 14 0
      PDFViewer.xcodeproj/xcuserdata/kdanmobile_2.xcuserdatad/xcschemes/xcschememanagement.plist
  5. 0 16
      PDFViewer/Controller/BatesAddViewController.h
  6. 0 31
      PDFViewer/Controller/BatesAddViewController.m
  7. 0 31
      PDFViewer/Controller/BatesDeleteViewController.m
  8. 0 16
      PDFViewer/Controller/BatesSettingViewController.h
  9. 0 31
      PDFViewer/Controller/BatesSettingViewController.m
  10. 30 0
      PDFViewer/Controller/CPDFBatesAddViewController.h
  11. 153 0
      PDFViewer/Controller/CPDFBatesAddViewController.m
  12. 1 1
      PDFViewer/Controller/BatesDeleteViewController.h
  13. 31 0
      PDFViewer/Controller/CPDFBatesDeleteViewController.m
  14. 21 0
      PDFViewer/Controller/CPDFBatesSettingController.h
  15. 52 0
      PDFViewer/Controller/CPDFBatesSettingController.m
  16. 53 0
      PDFViewer/Controller/CPDFHeaderFooterAddController.h
  17. 188 0
      PDFViewer/Controller/CPDFHeaderFooterAddController.m
  18. 35 0
      PDFViewer/Controller/CPDFHeaderFooterAddView.h
  19. 105 0
      PDFViewer/Controller/CPDFHeaderFooterAddView.m
  20. 1 1
      PDFViewer/Controller/HeaderFooterDeleteViewController.h
  21. 32 0
      PDFViewer/Controller/CPDFHeaderFooterDeleteController.m
  22. 29 0
      PDFViewer/Controller/CPDFHeaderFooterSettingController.h
  23. 63 0
      PDFViewer/Controller/CPDFHeaderFooterSettingController.m
  24. 1 0
      PDFViewer/Controller/CPDFViewController.h
  25. 31 13
      PDFViewer/Controller/CPDFViewController.m
  26. 0 16
      PDFViewer/Controller/HeaderFooterAddView.h
  27. 0 20
      PDFViewer/Controller/HeaderFooterAddView.m
  28. 0 16
      PDFViewer/Controller/HeaderFooterAlertViewController.h
  29. 0 31
      PDFViewer/Controller/HeaderFooterAlertViewController.m
  30. 0 31
      PDFViewer/Controller/HeaderFooterDeleteViewController.m
  31. 26 0
      PDFViewer/Masonry/Info.plist
  32. 26 0
      PDFViewer/Masonry/MASCompositeConstraint.h
  33. 183 0
      PDFViewer/Masonry/MASCompositeConstraint.m
  34. 66 0
      PDFViewer/Masonry/MASConstraint+Private.h
  35. 268 0
      PDFViewer/Masonry/MASConstraint.h
  36. 297 0
      PDFViewer/Masonry/MASConstraint.m
  37. 138 0
      PDFViewer/Masonry/MASConstraintMaker.h
  38. 261 0
      PDFViewer/Masonry/MASConstraintMaker.m
  39. 22 0
      PDFViewer/Masonry/MASLayoutConstraint.h
  40. 13 0
      PDFViewer/Masonry/MASLayoutConstraint.m
  41. 136 0
      PDFViewer/Masonry/MASUtilities.h
  42. 49 0
      PDFViewer/Masonry/MASViewAttribute.h
  43. 46 0
      PDFViewer/Masonry/MASViewAttribute.m
  44. 48 0
      PDFViewer/Masonry/MASViewConstraint.h
  45. 406 0
      PDFViewer/Masonry/MASViewConstraint.m
  46. 29 0
      PDFViewer/Masonry/Masonry.h
  47. 72 0
      PDFViewer/Masonry/NSArray+MASAdditions.h
  48. 162 0
      PDFViewer/Masonry/NSArray+MASAdditions.m
  49. 41 0
      PDFViewer/Masonry/NSArray+MASShorthandAdditions.h
  50. 16 0
      PDFViewer/Masonry/NSLayoutConstraint+MASDebugAdditions.h
  51. 143 0
      PDFViewer/Masonry/NSLayoutConstraint+MASDebugAdditions.m
  52. 109 0
      PDFViewer/Masonry/View+MASAdditions.h
  53. 206 0
      PDFViewer/Masonry/View+MASAdditions.m
  54. 138 0
      PDFViewer/Masonry/View+MASShorthandAdditions.h
  55. 29 0
      PDFViewer/Masonry/ViewController+MASAdditions.h
  56. 42 0
      PDFViewer/Masonry/ViewController+MASAdditions.m
  57. 24 0
      PDFViewer/Model/CPDFModelData.h
  58. 12 0
      PDFViewer/Model/CPDFModelData.m
  59. 0 16
      PDFViewer/View/BatesAddView.h
  60. 0 20
      PDFViewer/View/BatesAddView.m
  61. 31 0
      PDFViewer/View/CPDFBatesAddView.h
  62. 102 0
      PDFViewer/View/CPDFBatesAddView.m
  63. 31 0
      PDFViewer/View/CPDFDropDownView.h
  64. 99 0
      PDFViewer/View/CPDFDropDownView.m

+ 85 - 0
PDFViewer.xcodeproj/project.pbxproj

@@ -8,6 +8,20 @@
 
 /* Begin PBXBuildFile section */
 		C96D13932924793800CC92C7 /* btn_more.png in Resources */ = {isa = PBXBuildFile; fileRef = C96D13922924793800CC92C7 /* btn_more.png */; };
+		C96D13962924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m in Sources */ = {isa = PBXBuildFile; fileRef = C96D13952924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m */; };
+		C96D13992924E09300CC92C7 /* CPDFHeaderFooterAddView.m in Sources */ = {isa = PBXBuildFile; fileRef = C96D13982924E09300CC92C7 /* CPDFHeaderFooterAddView.m */; };
+		C993B8FB2925E14000D8F474 /* text_color_bar.png in Resources */ = {isa = PBXBuildFile; fileRef = C993B8FA2925E14000D8F474 /* text_color_bar.png */; };
+		C993B8FE2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */; };
+		C993B90229264DC900D8F474 /* CPDFBatesSettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90129264DC900D8F474 /* CPDFBatesSettingController.m */; };
+		C993B9042926541D00D8F474 /* add_newpage01.png in Resources */ = {isa = PBXBuildFile; fileRef = C993B9032926541D00D8F474 /* add_newpage01.png */; };
+		C993B9062926543500D8F474 /* pageedit_delete.png in Resources */ = {isa = PBXBuildFile; fileRef = C993B9052926543500D8F474 /* pageedit_delete.png */; };
+		C993B909292654BE00D8F474 /* CPDFBatesDeleteViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */; };
+		C993B90C29271FCA00D8F474 /* CPDFBatesAddViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */; };
+		C993B90F2927200400D8F474 /* CPDFBatesAddView.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B90E2927200400D8F474 /* CPDFBatesAddView.m */; };
+		C993B912292B07F600D8F474 /* CPDFHeaderFooterSettingController.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B911292B07F600D8F474 /* CPDFHeaderFooterSettingController.m */; };
+		C993B915292B1C4100D8F474 /* CPDFDropDownView.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B914292B1C4100D8F474 /* CPDFDropDownView.m */; };
+		C993B918292B5BC500D8F474 /* CPDFModelData.m in Sources */ = {isa = PBXBuildFile; fileRef = C993B917292B5BC500D8F474 /* CPDFModelData.m */; };
+		C993B91A292CAE2100D8F474 /* Masonry in Resources */ = {isa = PBXBuildFile; fileRef = C993B919292CAE2100D8F474 /* Masonry */; };
 		EC3198782922593A008E0889 /* ComPDFKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EC31987629225931008E0889 /* ComPDFKit.framework */; };
 		EC3198792922593A008E0889 /* ComPDFKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = EC31987629225931008E0889 /* ComPDFKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
 		EC62978E29220F8300D339EE /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = EC62978D29220F8300D339EE /* AppDelegate.m */; };
@@ -38,6 +52,30 @@
 
 /* Begin PBXFileReference section */
 		C96D13922924793800CC92C7 /* btn_more.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = btn_more.png; sourceTree = "<group>"; };
+		C96D13942924DD7E00CC92C7 /* CPDFHeaderFooterAddController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterAddController.h; sourceTree = "<group>"; };
+		C96D13952924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterAddController.m; sourceTree = "<group>"; };
+		C96D13972924E09300CC92C7 /* CPDFHeaderFooterAddView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CPDFHeaderFooterAddView.h; path = PDFViewer/Controller/CPDFHeaderFooterAddView.h; sourceTree = SOURCE_ROOT; };
+		C96D13982924E09300CC92C7 /* CPDFHeaderFooterAddView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CPDFHeaderFooterAddView.m; path = PDFViewer/Controller/CPDFHeaderFooterAddView.m; sourceTree = SOURCE_ROOT; };
+		C993B8FA2925E14000D8F474 /* text_color_bar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = text_color_bar.png; sourceTree = "<group>"; };
+		C993B8FC2925E52800D8F474 /* CPDFHeaderFooterDeleteController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterDeleteController.h; sourceTree = "<group>"; };
+		C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterDeleteController.m; sourceTree = "<group>"; };
+		C993B90029264DC900D8F474 /* CPDFBatesSettingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesSettingController.h; sourceTree = "<group>"; };
+		C993B90129264DC900D8F474 /* CPDFBatesSettingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesSettingController.m; sourceTree = "<group>"; };
+		C993B9032926541D00D8F474 /* add_newpage01.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add_newpage01.png; sourceTree = "<group>"; };
+		C993B9052926543500D8F474 /* pageedit_delete.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pageedit_delete.png; sourceTree = "<group>"; };
+		C993B907292654BE00D8F474 /* CPDFBatesDeleteViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesDeleteViewController.h; sourceTree = "<group>"; };
+		C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesDeleteViewController.m; sourceTree = "<group>"; };
+		C993B90A29271FCA00D8F474 /* CPDFBatesAddViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesAddViewController.h; sourceTree = "<group>"; };
+		C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesAddViewController.m; sourceTree = "<group>"; };
+		C993B90D2927200400D8F474 /* CPDFBatesAddView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFBatesAddView.h; sourceTree = "<group>"; };
+		C993B90E2927200400D8F474 /* CPDFBatesAddView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFBatesAddView.m; sourceTree = "<group>"; };
+		C993B910292B07F600D8F474 /* CPDFHeaderFooterSettingController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFHeaderFooterSettingController.h; sourceTree = "<group>"; };
+		C993B911292B07F600D8F474 /* CPDFHeaderFooterSettingController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFHeaderFooterSettingController.m; sourceTree = "<group>"; };
+		C993B913292B1C4100D8F474 /* CPDFDropDownView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFDropDownView.h; sourceTree = "<group>"; };
+		C993B914292B1C4100D8F474 /* CPDFDropDownView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFDropDownView.m; sourceTree = "<group>"; };
+		C993B916292B5BC500D8F474 /* CPDFModelData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFModelData.h; sourceTree = "<group>"; };
+		C993B917292B5BC500D8F474 /* CPDFModelData.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFModelData.m; sourceTree = "<group>"; };
+		C993B919292CAE2100D8F474 /* Masonry */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Masonry; sourceTree = "<group>"; };
 		EC31987629225931008E0889 /* ComPDFKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = ComPDFKit.framework; sourceTree = "<group>"; };
 		EC62978929220F8300D339EE /* PDFViewer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PDFViewer.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		EC62978C29220F8300D339EE /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
@@ -74,11 +112,22 @@
 		C96D13912924791E00CC92C7 /* Images */ = {
 			isa = PBXGroup;
 			children = (
+				C993B9032926541D00D8F474 /* add_newpage01.png */,
 				C96D13922924793800CC92C7 /* btn_more.png */,
+				C993B9052926543500D8F474 /* pageedit_delete.png */,
 			);
 			path = Images;
 			sourceTree = "<group>";
 		};
+		C993B8F92925E12B00D8F474 /* Image */ = {
+			isa = PBXGroup;
+			children = (
+				C993B8FA2925E14000D8F474 /* text_color_bar.png */,
+			);
+			name = Image;
+			path = PDFViewer/View/Image;
+			sourceTree = "<group>";
+		};
 		EC62978029220F8300D339EE = {
 			isa = PBXGroup;
 			children = (
@@ -99,6 +148,7 @@
 		EC62978B29220F8300D339EE /* PDFViewer */ = {
 			isa = PBXGroup;
 			children = (
+				C993B919292CAE2100D8F474 /* Masonry */,
 				EC6297B52922393F00D339EE /* Controller */,
 				EC6297AD29222D3100D339EE /* Model */,
 				EC6297AE29222D4400D339EE /* View */,
@@ -122,6 +172,8 @@
 			children = (
 				EC6297B6292239A700D339EE /* CPDFModel.h */,
 				EC6297B7292239A700D339EE /* CPDFModel.m */,
+				C993B916292B5BC500D8F474 /* CPDFModelData.h */,
+				C993B917292B5BC500D8F474 /* CPDFModelData.m */,
 			);
 			path = Model;
 			sourceTree = "<group>";
@@ -129,6 +181,13 @@
 		EC6297AE29222D4400D339EE /* View */ = {
 			isa = PBXGroup;
 			children = (
+				C993B8F92925E12B00D8F474 /* Image */,
+				C96D13972924E09300CC92C7 /* CPDFHeaderFooterAddView.h */,
+				C96D13982924E09300CC92C7 /* CPDFHeaderFooterAddView.m */,
+				C993B90D2927200400D8F474 /* CPDFBatesAddView.h */,
+				C993B90E2927200400D8F474 /* CPDFBatesAddView.m */,
+				C993B913292B1C4100D8F474 /* CPDFDropDownView.h */,
+				C993B914292B1C4100D8F474 /* CPDFDropDownView.m */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -141,6 +200,18 @@
 				EC6297BC292239C200D339EE /* CPDFListController.m */,
 				ECC8831B2923352B00F6392E /* CPDFViewController.h */,
 				ECC8831C2923352B00F6392E /* CPDFViewController.m */,
+				C96D13942924DD7E00CC92C7 /* CPDFHeaderFooterAddController.h */,
+				C96D13952924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m */,
+				C993B8FC2925E52800D8F474 /* CPDFHeaderFooterDeleteController.h */,
+				C993B8FD2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m */,
+				C993B90029264DC900D8F474 /* CPDFBatesSettingController.h */,
+				C993B90129264DC900D8F474 /* CPDFBatesSettingController.m */,
+				C993B907292654BE00D8F474 /* CPDFBatesDeleteViewController.h */,
+				C993B908292654BE00D8F474 /* CPDFBatesDeleteViewController.m */,
+				C993B90A29271FCA00D8F474 /* CPDFBatesAddViewController.h */,
+				C993B90B29271FCA00D8F474 /* CPDFBatesAddViewController.m */,
+				C993B910292B07F600D8F474 /* CPDFHeaderFooterSettingController.h */,
+				C993B911292B07F600D8F474 /* CPDFHeaderFooterSettingController.m */,
 			);
 			path = Controller;
 			sourceTree = "<group>";
@@ -202,9 +273,13 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				C993B91A292CAE2100D8F474 /* Masonry in Resources */,
 				EC62979C29220F8400D339EE /* LaunchScreen.storyboard in Resources */,
 				C96D13932924793800CC92C7 /* btn_more.png in Resources */,
+				C993B9042926541D00D8F474 /* add_newpage01.png in Resources */,
 				EC62979929220F8400D339EE /* Assets.xcassets in Resources */,
+				C993B9062926543500D8F474 /* pageedit_delete.png in Resources */,
+				C993B8FB2925E14000D8F474 /* text_color_bar.png in Resources */,
 				EC62979729220F8300D339EE /* Main.storyboard in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
@@ -216,11 +291,21 @@
 			isa = PBXSourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				C96D13992924E09300CC92C7 /* CPDFHeaderFooterAddView.m in Sources */,
+				C993B915292B1C4100D8F474 /* CPDFDropDownView.m in Sources */,
 				ECC8831D2923352B00F6392E /* CPDFViewController.m in Sources */,
+				C993B918292B5BC500D8F474 /* CPDFModelData.m in Sources */,
+				C96D13962924DD7E00CC92C7 /* CPDFHeaderFooterAddController.m in Sources */,
+				C993B909292654BE00D8F474 /* CPDFBatesDeleteViewController.m in Sources */,
 				EC62979429220F8300D339EE /* ViewController.m in Sources */,
 				EC6297B8292239A700D339EE /* CPDFModel.m in Sources */,
+				C993B90C29271FCA00D8F474 /* CPDFBatesAddViewController.m in Sources */,
+				C993B90229264DC900D8F474 /* CPDFBatesSettingController.m in Sources */,
+				C993B90F2927200400D8F474 /* CPDFBatesAddView.m in Sources */,
+				C993B912292B07F600D8F474 /* CPDFHeaderFooterSettingController.m in Sources */,
 				EC62978E29220F8300D339EE /* AppDelegate.m in Sources */,
 				EC62979F29220F8400D339EE /* main.m in Sources */,
+				C993B8FE2925E52800D8F474 /* CPDFHeaderFooterDeleteController.m in Sources */,
 				EC6297BD292239C200D339EE /* CPDFListController.m in Sources */,
 				EC62979129220F8300D339EE /* SceneDelegate.m in Sources */,
 			);

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


+ 104 - 0
PDFViewer.xcodeproj/xcuserdata/kdanmobile_2.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

@@ -0,0 +1,104 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Bucket
+   uuid = "C9705E14-C79F-4D2A-ADF6-CE5D16F03E83"
+   type = "1"
+   version = "2.0">
+   <Breakpoints>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "0D73DBC1-666A-414F-80BE-9189EC89462F"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDFViewer/Controller/CPDFViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "2"
+            endingLineNumber = "2"
+            landmarkName = "unknown"
+            landmarkType = "0">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "586B4355-6698-4BE5-A394-4B232CE80318"
+            shouldBeEnabled = "No"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDFViewer/Controller/HeaderFooterAlertViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "41"
+            endingLineNumber = "41"
+            landmarkName = "-viewDidLoad"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "05C2F84D-3598-4B1E-8CAA-E3E0C49A840F"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDFViewer/Controller/HeaderFooterAlertViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "30"
+            endingLineNumber = "30"
+            landmarkName = "-viewDidLoad"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "FE064F60-543B-4BD1-8A92-595D053B00F0"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDFViewer/Controller/HeaderFooterAlertViewController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "112"
+            endingLineNumber = "112"
+            landmarkName = "-showPages"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "A50A5C35-B3BE-43DE-A535-6906058FECEB"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDFViewer/Controller/CPDFHeaderFooterAddController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "65"
+            endingLineNumber = "65"
+            landmarkName = "-doneClick:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+      <BreakpointProxy
+         BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
+         <BreakpointContent
+            uuid = "8893661F-BBCA-427A-9B71-FA0204E29B92"
+            shouldBeEnabled = "Yes"
+            ignoreCount = "0"
+            continueAfterRunningActions = "No"
+            filePath = "PDFViewer/Controller/CPDFHeaderFooterSettingController.m"
+            startingColumnNumber = "9223372036854775807"
+            endingColumnNumber = "9223372036854775807"
+            startingLineNumber = "59"
+            endingLineNumber = "59"
+            landmarkName = "-getModel:"
+            landmarkType = "7">
+         </BreakpointContent>
+      </BreakpointProxy>
+   </Breakpoints>
+</Bucket>

+ 14 - 0
PDFViewer.xcodeproj/xcuserdata/kdanmobile_2.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>SchemeUserState</key>
+	<dict>
+		<key>PDFViewer.xcscheme_^#shared#^_</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>0</integer>
+		</dict>
+	</dict>
+</dict>
+</plist>

+ 0 - 16
PDFViewer/Controller/BatesAddViewController.h

@@ -1,16 +0,0 @@
-//
-//  BatesAddViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/18.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface BatesAddViewController : UIViewController
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 31
PDFViewer/Controller/BatesAddViewController.m

@@ -1,31 +0,0 @@
-//
-//  BatesAddViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/18.
-//
-
-#import "BatesAddViewController.h"
-
-@interface BatesAddViewController ()
-
-@end
-
-@implementation BatesAddViewController
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-}
-
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
-
-@end

+ 0 - 31
PDFViewer/Controller/BatesDeleteViewController.m

@@ -1,31 +0,0 @@
-//
-//  BatesDeleteViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import "BatesDeleteViewController.h"
-
-@interface BatesDeleteViewController ()
-
-@end
-
-@implementation BatesDeleteViewController
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-}
-
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
-
-@end

+ 0 - 16
PDFViewer/Controller/BatesSettingViewController.h

@@ -1,16 +0,0 @@
-//
-//  BatesSettingViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface BatesSettingViewController : UIViewController
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 31
PDFViewer/Controller/BatesSettingViewController.m

@@ -1,31 +0,0 @@
-//
-//  BatesSettingViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import "BatesSettingViewController.h"
-
-@interface BatesSettingViewController ()
-
-@end
-
-@implementation BatesSettingViewController
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-}
-
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
-
-@end

+ 30 - 0
PDFViewer/Controller/CPDFBatesAddViewController.h

@@ -0,0 +1,30 @@
+//
+//  BatesAddViewController.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/18.
+//
+
+#import <UIKit/UIKit.h>
+#import "CPDFBatesAddView.h"
+#import "CPDFHeaderFooterAddController.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFBatesAddViewController : UIViewController
+
+- (void)cancelClick:(UIBarButtonItem *)btn;
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
+- (void)changeLocation:(UISegmentedControl *)sender;
+- (void)changeAligbment:(UISegmentedControl *)sender;
+- (void)sliderChange:(UISlider *)slider;
+
+@property (nonatomic,strong) UIImage *image;
+@property (nonatomic,assign) CGSize size;
+@property (nonatomic,assign) Position position;
+@property (nonatomic,strong) CPDFBatesAddView *batesAddView;
+@property (nonatomic,strong) UILabel *showLabel;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 153 - 0
PDFViewer/Controller/CPDFBatesAddViewController.m

@@ -0,0 +1,153 @@
+//
+//  BatesAddViewController.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/18.
+//
+
+#import "CPDFBatesAddViewController.h"
+
+@interface CPDFBatesAddViewController ()
+
+@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.
+    self.navigationItem.title = @"Add Bates/";
+    self.navigationController.toolbarHidden = NO;
+    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:nil action:nil];
+    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelClick:)];
+    //add page image
+    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((393/2)-(self.size.width/6), 175, self.size.width/3, self.size.height/3)];
+    imageView.image = self.image;
+    CALayer *layer = [imageView layer];
+    layer.borderColor = [[UIColor blackColor] CGColor];
+    layer.borderWidth = 1.0f;
+    [self.view addSubview:imageView];
+    //add view
+    _batesAddView = [[CPDFBatesAddView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height/2, self.view.frame.size.width, self.view.frame.size.height)];
+    [self.view addSubview:_batesAddView];
+    [ _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)cancelClick:(UIBarButtonItem *)btn {
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+//slider select color
+- (void)sliderChange:(UISlider *)slider {
+    switch ((int)slider.value/10) {
+        case 0:
+            self.showLabel.textColor = [UIColor redColor];
+            break;
+        case 1:
+            self.showLabel.textColor = [UIColor orangeColor];
+            break;
+        case 2:
+            self.showLabel.textColor = [UIColor colorWithRed:239.0/255 green:140.0/255 blue:133.0/255 alpha:1];
+            break;
+        case 3:
+            self.showLabel.textColor = [UIColor yellowColor];
+            break;
+        case 4:
+            self.showLabel.textColor = [UIColor greenColor];
+            break;
+        case 5:
+            self.showLabel.textColor = [UIColor blueColor];
+            break;
+        case 6:
+            self.showLabel.textColor = [UIColor purpleColor];
+            break;
+        case 7:
+            self.showLabel.textColor = [UIColor colorWithRed:235.0/255 green:61.0/255 blue:133.0/255 alpha:1];
+            break;
+        case 8:
+            self.showLabel.textColor = [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];
+    }
+    switch (self.position.location) {
+        case kHeader:
+            NSLog(@"header");
+            switch (self.position.aligment) {
+                case kLeft:
+                    _showLabel.frame = CGRectMake((393/2)-(self.size.width/6)+2, 177, 5, 5);
+                    break;
+                case kCenter:
+                    _showLabel.frame = CGRectMake(393/2, 177, 5, 5);
+                    break;
+                case kRinght:
+                    _showLabel.frame = CGRectMake((393/2)+(self.size.width/6)-7, 177, 5, 5);
+                    break;
+                default:
+                    break;
+            }
+            break;
+        case kFooter:
+            NSLog(@"Footer");
+            switch (self.position.aligment) {
+                case kLeft:
+                    _showLabel.frame = CGRectMake((393/2)-(self.size.width/6)+2, 170+self.size.height/3, 5, 5);
+                    break;
+                case kCenter:
+                    _showLabel.frame = CGRectMake(393/2, 170+self.size.height/3, 5, 5);
+                    break;
+                case kRinght:
+                    _showLabel.frame = CGRectMake((393/2)+(self.size.width/6)-7, 170+self.size.height/3, 5, 5);
+                    break;
+                default:
+                    break;
+            }
+            break;
+        default:
+            break;
+    }
+    [_showLabel setText:@"1"];
+    [self.view addSubview:_showLabel];
+}
+
+@end

+ 1 - 1
PDFViewer/Controller/BatesDeleteViewController.h

@@ -9,7 +9,7 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface BatesDeleteViewController : UIViewController
+@interface CPDFBatesDeleteViewController : UIViewController
 
 @end
 

+ 31 - 0
PDFViewer/Controller/CPDFBatesDeleteViewController.m

@@ -0,0 +1,31 @@
+//
+//  BatesDeleteViewController.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/17.
+//
+
+#import "CPDFBatesDeleteViewController.h"
+
+@interface CPDFBatesDeleteViewController ()
+
+@end
+
+@implementation CPDFBatesDeleteViewController
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Delete Bates" message:@"Are you sure delete all Bates" preferredStyle:UIAlertControllerStyleAlert];
+    UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+            NSLog(@"OK Action");
+        }];
+    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];
+}
+
+@end

+ 21 - 0
PDFViewer/Controller/CPDFBatesSettingController.h

@@ -0,0 +1,21 @@
+//
+//  BatesSettingViewController.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/17.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFBatesSettingController : UIViewController
+
+@property (nonatomic,strong) UIImage *image;
+@property (nonatomic,assign) CGSize size;
+
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 52 - 0
PDFViewer/Controller/CPDFBatesSettingController.m

@@ -0,0 +1,52 @@
+//
+//  BatesSettingViewController.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/17.
+//
+
+#import "CPDFBatesSettingController.h"
+#import "CPDFBatesDeleteViewController.h"
+#import "CPDFBatesAddViewController.h"
+
+@interface CPDFBatesSettingController ()
+
+@end
+
+@implementation CPDFBatesSettingController
+
+- (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.
+    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 addChildViewController:batesAddControl];
+        [self.view addSubview:batesAddControl.view];
+        [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];
+        [self.navigationController pushViewController:batesDeleteControl animated:NO];
+        }];
+    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];
+}
+
+@end

+ 53 - 0
PDFViewer/Controller/CPDFHeaderFooterAddController.h

@@ -0,0 +1,53 @@
+//
+//  HeaderFooterAlertViewController.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/16.
+//
+
+#import <UIKit/UIKit.h>
+#import <ComPDFKit/CPDFHeaderFooter.h>
+#import <ComPDFKit/ComPDFKit.h>
+#import "CPDFHeaderFooterAddView.h"
+#import "CPDFModelData.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef enum Location {
+    kHeader = 0,
+    kFooter,
+}Location;
+
+typedef enum Aligment {
+    kLeft = 0,
+    kCenter,
+    kRinght,
+}Aligment;
+
+typedef struct Position {
+    Location location;
+    Aligment aligment;
+}Position;
+
+@interface CPDFHeaderFooterAddController : UIViewController
+
+- (void)cancelClick:(UIBarButtonItem *)btn;
+- (void)doneClick:(UIBarButtonItem *)btn;
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *) pdfView;
+- (void)changeLocation:(UISegmentedControl *)sender;
+- (void)changeAligbment:(UISegmentedControl *)sender;
+- (void)sliderChange:(UISlider *)slider;
+ 
+@property (nonatomic,assign) CGSize size;
+@property (nonatomic,strong) UIImage *image;
+@property (nonatomic,assign) Position position;
+@property (nonatomic,strong) CPDFHeaderFooterAddView *headerFooterview;
+@property (nonatomic,strong) UILabel *showLabel;
+@property (nonatomic,strong) CPDFModelData *modelData;
+@property (nonatomic,strong) CPDFDocument *document;
+@property (nonatomic,strong) CPDFHeaderFooter *headerFooter;
+@property (nonatomic,strong) CPDFView *pdfView;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 188 - 0
PDFViewer/Controller/CPDFHeaderFooterAddController.m

@@ -0,0 +1,188 @@
+//
+//  HeaderFooterAlertViewController.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/16.
+//
+
+#import "CPDFHeaderFooterAddController.h"
+
+@interface CPDFHeaderFooterAddController ()
+
+@end
+
+@implementation CPDFHeaderFooterAddController
+
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *) pdfView {
+    self = [super init];
+    if (self) {
+        _image = image;
+        _size  = size;
+        _document = docment;
+        _pdfView = pdfView;
+    }
+    return self;
+}
+
+- (void)viewDidLoad { 
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    //setting navigation
+    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
+    _modelData = [[CPDFModelData alloc] init];
+    //add page image
+    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake((393/2)-(self.size.width/6), 125, self.size.width/3, self.size.height/3)];
+    imageView.image = self.image;
+    CALayer *layer = [imageView layer];
+    layer.borderColor = [[UIColor blackColor] CGColor];
+    layer.borderWidth = 1.0f;
+    [self.view addSubview:imageView];
+    //add view
+    _headerFooterview = [[CPDFHeaderFooterAddView alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height/2, self.view.frame.size.width, self.view.frame.size.height)];
+    [self.view addSubview:_headerFooterview];
+    [_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)cancelClick:(UIBarButtonItem *)btn {
+    [self.navigationController popViewControllerAnimated:YES];
+}
+
+- (void)doneClick:(UIBarButtonItem *)btn {
+    /*self.headerFooter = [self.document headerFooter];
+    [self.headerFooter clear];
+    self.headerFooter.pageString = @"2";
+    [self.headerFooter setText:@"1" atIndex:1];
+    [self.headerFooter setTextColor:self.modelData.fontColor atIndex:self.modelData.fontPosition];
+    [self.headerFooter update];*/
+    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"model", nil];
+    NSNotification *notification = [NSNotification notificationWithName:@"changeModel" object:nil userInfo:dict];
+    [[NSNotificationCenter defaultCenter] postNotification:notification];
+    [self.navigationController popViewControllerAnimated:YES];
+    //[self.navigationController popViewControllerAnimated:YES];
+}
+
+//slider select color
+- (void)sliderChange:(UISlider *)slider {
+    switch ((int)slider.value/10) {
+        case 0:
+            self.showLabel.textColor = [UIColor redColor];
+            self.modelData.fontColor = [UIColor redColor];
+            break;
+        case 1:
+            self.showLabel.textColor = [UIColor orangeColor];
+            self.modelData.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.modelData.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.modelData.fontColor = [UIColor yellowColor];;
+            break;
+        case 4:
+            self.showLabel.textColor = [UIColor greenColor];
+            self.modelData.fontColor = [UIColor greenColor];
+            break;
+        case 5:
+            self.showLabel.textColor = [UIColor blueColor];
+            self.modelData.fontColor = [UIColor blueColor];
+            break;
+        case 6:
+            self.showLabel.textColor = [UIColor purpleColor];
+            self.modelData.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.modelData.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.modelData.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];
+    }
+    switch (self.position.location) {
+        case kHeader:
+            NSLog(@"header");
+            switch (self.position.aligment) {
+                case kLeft:
+                    _showLabel.frame = CGRectMake((393/2)-(self.size.width/6)+2, 177, 5, 5);
+                    self.modelData.fontPosition = 0;
+                    break;
+                case kCenter:
+                    _showLabel.frame = CGRectMake(393/2, 177, 5, 5);
+                    self.modelData.fontPosition = 1;
+                    break;
+                case kRinght:
+                    _showLabel.frame = CGRectMake((393/2)+(self.size.width/6)-7, 177, 5, 5);
+                    self.modelData.fontPosition = 2;
+                    break;
+                default:
+                    break;
+            }
+            break;
+        case kFooter:
+            NSLog(@"Footer");
+            switch (self.position.aligment) {
+                case kLeft:
+                    _showLabel.frame = CGRectMake((393/2)-(self.size.width/6)+2, 170+self.size.height/3, 5, 5);
+                    self.modelData.fontPosition = 3;
+                    break;
+                case kCenter:
+                    _showLabel.frame = CGRectMake(393/2, 170+self.size.height/3, 5, 5);
+                    self.modelData.fontPosition = 4;
+                    break;
+                case kRinght:
+                    _showLabel.frame = CGRectMake((393/2)+(self.size.width/6)-7, 170+self.size.height/3, 5, 5);
+                    self.modelData.fontPosition = 5;
+                    break;
+                default:
+                    break;
+            }
+            break;
+        default:
+            break;
+    }
+    [_showLabel setText:@"1"];
+    [self.view addSubview:_showLabel];
+}
+
+@end

+ 35 - 0
PDFViewer/Controller/CPDFHeaderFooterAddView.h

@@ -0,0 +1,35 @@
+//
+//  HeaderFooterAddView.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/16.
+//
+
+#import <UIKit/UIKit.h>
+#import "CPDFDropDownView.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFHeaderFooterAddView : 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;
+@property (nonatomic,strong) UILabel *pageNumberLabel;
+@property (nonatomic,strong) UITextField *pageNumberText;
+@property (nonatomic,strong) CPDFDropDownView *dropdownView;
+@property (nonatomic,strong) UILabel *fontSizeLabel;
+@property (nonatomic,strong) UITextField *fontSizeText;
+@property (nonatomic,strong) UILabel *pageIndexLabel;
+@property (nonatomic,strong) UILabel *pageIndexNumberLabel;
+@property (nonatomic,strong) UIStepper *pageIndexNumberStepper;
+
+- (void)stepperValueChanged:(UIStepper *)pageIndexNumberStepper;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 105 - 0
PDFViewer/Controller/CPDFHeaderFooterAddView.m

@@ -0,0 +1,105 @@
+//
+//  HeaderFooterAddView.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/16.
+//
+
+#import "CPDFHeaderFooterAddView.h"
+
+@implementation CPDFHeaderFooterAddView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    self = [super initWithFrame:frame];
+    CGFloat height = self.bounds.size.height / 15 - 35;
+    CGFloat width  = self.bounds.size.width / 4 - 10;
+    CGFloat offsetx = 3.5;
+    if (self) {
+        //Page number location
+        _localLabel = [[UILabel alloc] initWithFrame:CGRectMake(offsetx, offsetx, width * 2, height)];
+        [_localLabel setText:@"Page number position"];
+        _localLabel.font = [UIFont boldSystemFontOfSize:12];
+        NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
+        _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
+        _localSegment.frame = CGRectMake(4 * offsetx, height + 2 * offsetx, self.bounds.size.width - 8 * offsetx, height * 2);
+        [self addSubview:_localLabel];
+        [self addSubview:_localSegment];
+        //alignment
+        _alignmentLabel = [[UILabel alloc] initWithFrame:CGRectMake(3.5, 3 * height + 3 * offsetx, width, height)];
+        [_alignmentLabel setText:@"alignment"];
+        _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
+        NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
+        _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
+        _aligbmentSegment.frame = CGRectMake(4 * offsetx, 4 * height + 4 * offsetx, self.bounds.size.width - 8 * offsetx, height * 2);
+        [self addSubview:_alignmentLabel];
+        [self addSubview:_aligbmentSegment];
+        //font color
+        _colorLabel = [[UILabel alloc] initWithFrame:CGRectMake(3.5, 6 * height + 5 * offsetx, width, height)];
+        [_colorLabel setText:@"Font Color"];
+        _colorLabel.font = [UIFont boldSystemFontOfSize:12];
+        _colerImage = [[UIImageView alloc] initWithFrame:CGRectMake(4 * offsetx,7 * height + 6 * offsetx , self.bounds.size.width, 2*height)];
+        _colerImage.image = [UIImage imageNamed:@"text_color_bar"];
+        _colorSlider = [[UISlider alloc] initWithFrame:CGRectMake(4 * offsetx,9 * height + 7 * offsetx , self.bounds.size.width - 8 * offsetx, 2 * height)];
+        _colorSlider.minimumValue = 0;
+        _colorSlider.maximumValue = 90;
+        _colorSlider.value = 5;
+        [self addSubview:_colorLabel];
+        [self addSubview:_colorSlider];
+        [self addSubview:_colerImage];
+        //page number
+        _pageNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(3.5, 11 * height + 8 * offsetx, width + offsetx, height * 2)];
+        [_pageNumberLabel setText:@"Page Text"];
+        _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
+        NSArray *str = [[NSArray alloc] initWithObjects:@"1",@"第1页", nil];
+        _dropdownView = [[CPDFDropDownView alloc] initWithFrame:CGRectMake(2 * offsetx + width, 11 * height + 8 * offsetx, width - offsetx, height * 2) WithString:str];
+        [self addSubview:_dropdownView];
+        [self addSubview:_pageNumberLabel];
+        //font size
+        _fontSizeLabel = [[UILabel alloc] initWithFrame:CGRectMake(3 * offsetx + width * 2, 11 * height + 8 * offsetx, width, height * 2)];
+        [_fontSizeLabel setText:@"Font Szie"];
+        _fontSizeLabel.font = [UIFont boldSystemFontOfSize:14];
+        _fontSizeText = [[UITextField alloc] initWithFrame:CGRectMake(2 * offsetx + 3 * width, 11 * height + 8 * offsetx, width, height * 2)];
+        _fontSizeText.borderStyle = UITextBorderStyleRoundedRect;
+        [self addSubview:_fontSizeLabel];
+        [self addSubview:_fontSizeText];
+        //font index
+        _pageIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(offsetx, 13 * height + 9 * offsetx, width, height * 2)];
+        [_pageIndexLabel setText:@"Page Star"];
+        _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
+        _pageIndexNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(offsetx + width, 13 * height + 10 * offsetx, width, height * 2)];
+        _pageIndexNumberLabel.backgroundColor = [UIColor whiteColor];
+        _pageIndexNumberLabel.textColor = [UIColor blackColor];
+        _pageIndexNumberLabel.textAlignment = NSTextAlignmentCenter;
+        _pageIndexNumberStepper = [[UIStepper alloc] initWithFrame:CGRectMake(offsetx + width * 2, 13 * height + 11 * offsetx, width, height * 2)];
+        // The step value is updated in real time as the user interacts
+        _pageIndexNumberStepper.continuous = YES; // default = YES
+        // The user continues to press and hold, automatically increasing or decreasing
+        _pageIndexNumberStepper.autorepeat = YES; // default = YES
+        // If set to YES, the value loops between min <-> max
+        _pageIndexNumberStepper.wraps = NO; // default = NO
+        _pageIndexNumberStepper.minimumValue = 1;   // default 0
+        _pageIndexNumberStepper.maximumValue = 100; // default 100
+        _pageIndexNumberStepper.stepValue    = 1;   // default 1
+        _pageIndexNumberStepper.value = 1;
+        // 设置 Target-Action
+        [_pageIndexNumberStepper addTarget:self
+                    action:@selector(stepperValueChanged:)
+          forControlEvents:UIControlEventValueChanged];
+        [self addSubview:_pageIndexLabel];
+        [self addSubview:_pageIndexNumberLabel];
+        [self addSubview:_pageIndexNumberStepper];
+        
+        self.backgroundColor = [UIColor whiteColor];
+    }
+    return  self;
+}
+
+- (void)stepperValueChanged:(UIStepper *)pageIndexNumberStepper {
+    int pageIndex = (int)pageIndexNumberStepper.value;
+    NSString *value = [NSString stringWithFormat:@"%d",pageIndex];
+    self.pageIndexLabel.font = [UIFont boldSystemFontOfSize:12.0];
+    self.pageIndexNumberLabel.text = value;
+}
+
+@end
+

+ 1 - 1
PDFViewer/Controller/HeaderFooterDeleteViewController.h

@@ -9,7 +9,7 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-@interface HeaderFooterDeleteViewController : UIViewController
+@interface CPDFHeaderFooterDeleteController : UIViewController
 
 @end
 

+ 32 - 0
PDFViewer/Controller/CPDFHeaderFooterDeleteController.m

@@ -0,0 +1,32 @@
+//
+//  HeaderFooterDeleteViewController.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/17.
+//
+
+#import "CPDFHeaderFooterDeleteController.h"
+
+@interface CPDFHeaderFooterDeleteController ()
+
+#define PAGENUMBER YES;
+
+@end
+
+@implementation CPDFHeaderFooterDeleteController
+
+- (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) {
+            NSLog(@"OK Action");
+        }];
+    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];
+}
+
+@end

+ 29 - 0
PDFViewer/Controller/CPDFHeaderFooterSettingController.h

@@ -0,0 +1,29 @@
+//
+//  HeaderFooterSettingViewController.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/21.
+//
+
+#import <UIKit/UIKit.h>
+#import <ComPDFKit/ComPDFKit.h>
+#import "CPDFHeaderFooterAddController.h"
+#import "CPDFHeaderFooterDeleteController.h"
+#import "CPDFModelData.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFHeaderFooterSettingController : UIViewController
+
+@property (nonatomic,strong) UIImage *image;
+@property (nonatomic,assign) CGSize size;
+@property (nonatomic,strong) CPDFDocument *document;
+@property (nonatomic,strong) CPDFView *pdfView;
+@property (nonatomic,strong) CPDFHeaderFooterAddController *headerFooterControl;
+@property (nonatomic,strong) CPDFModelData *modelData;
+
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment WithView:(CPDFView *) pdfView;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 63 - 0
PDFViewer/Controller/CPDFHeaderFooterSettingController.m

@@ -0,0 +1,63 @@
+//
+//  HeaderFooterSettingViewController.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/21.
+//
+
+#import "CPDFHeaderFooterSettingController.h"
+
+@interface CPDFHeaderFooterSettingController ()
+
+@end
+
+@implementation CPDFHeaderFooterSettingController
+
+- (id)initWithIamge:(UIImage *)image WithSize:(CGSize)size WithDocument:(CPDFDocument *)docment  WithView:(CPDFView *) pdfView {
+    self = [super init];
+    if (self) {
+        _image = image;
+        _size  = size;
+        _document = docment;
+        _pdfView = pdfView;
+    }
+    return self;
+}
+
+- (void)viewDidLoad {
+    [super viewDidLoad];
+    // Do any additional setup after loading the view.
+    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
+    //add headerfooter action
+    UIAlertAction *addHeaderfooterAction = [UIAlertAction actionWithTitle:@"Add Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
+        self.headerFooterControl = [[CPDFHeaderFooterAddController alloc] initWithIamge:self.image WithSize:self.size WithDocument:self.document WithView:self.pdfView];
+        [self addChildViewController:self.headerFooterControl];
+        [self.view addSubview:self.headerFooterControl.view];
+        [self.navigationController pushViewController:self.headerFooterControl animated:NO];
+        self.view.hidden = YES;
+        }];
+    //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];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getModel:) name:@"changeModel" object:nil];
+}
+
+- (void)getModel:(NSNotification *)text {
+    self.modelData = self.headerFooterControl.modelData;
+    NSDictionary *dict = [[NSDictionary alloc] initWithObjectsAndKeys:self.modelData,@"model", nil];
+    NSNotification *notification = [NSNotification notificationWithName:@"getSettingModel" object:nil userInfo:dict];
+    [[NSNotificationCenter defaultCenter] postNotification:notification];
+}
+
+@end

+ 1 - 0
PDFViewer/Controller/CPDFViewController.h

@@ -6,6 +6,7 @@
 //
 
 #import <UIKit/UIKit.h>
+#import "CPDFModelData.h"
 
 NS_ASSUME_NONNULL_BEGIN
 

+ 31 - 13
PDFViewer/Controller/CPDFViewController.m

@@ -19,6 +19,9 @@
 @property (nonatomic,assign) CGSize size;
 @property (nonatomic,strong) CPDFHeaderFooter *headerFooter;
 @property (nonatomic,strong) CPDFDocument *document;
+@property (nonatomic,strong) CPDFView *pdfView;
+@property (nonatomic,strong) CPDFHeaderFooterSettingController *headefooterControl;
+@property (nonatomic,strong) CPDFModelData *modelData;
 
 @end
 
@@ -35,7 +38,7 @@
     [super viewDidLoad];
     // Do any additional setup after loading the view.
     //add UIBarButtonItem in Navigation
-    self.navigationController.toolbarHidden = NO;
+    self.navigationController.toolbarHidden = YES;
     UIImage *btnMore = [UIImage imageNamed:@"btn_more"];
     UIBarButtonItem *ringhtBarItem = [[UIBarButtonItem alloc] initWithImage:btnMore style:UIBarButtonItemStylePlain target:self action:@selector(onClickedOkbtn)];
     self.navigationItem.rightBarButtonItem = ringhtBarItem;
@@ -46,15 +49,11 @@
     CPDFPage *page = [_document pageAtIndex:0];
     _size = [_document pageSizeAtIndex:0];
     _image = [page thumbnailOfSize:_size];
-    //get document headerfooter
-    //_headerFooter = [_document headerFooter];
-    //[_headerFooter setText:@"1" atIndex:1];
-    //[_headerFooter update];
     //get document view
-    CPDFView *pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
-    pdfView.document = _document;
-    pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
-   [self.view addSubview:pdfView];
+    _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
+    _pdfView.document = _document;
+    _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+   [self.view addSubview:_pdfView];
 }
 
 - (void)onClickedOkbtn {
@@ -65,10 +64,10 @@
         }];
     //setting headerfooter action
     UIAlertAction *settingHeaderFooter = [UIAlertAction actionWithTitle:@"Setting Headerfooter" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
-        CPDFHeaderFooterSettingController *headefooterControl = [[CPDFHeaderFooterSettingController alloc] initWithIamge:self.image WithSize:self.size WithDocument:self.document];
-        [self addChildViewController:headefooterControl];
-        [self.view addSubview:headefooterControl.view];
-        [self.navigationController pushViewController:headefooterControl animated:NO];
+        self.headefooterControl = [[CPDFHeaderFooterSettingController alloc] initWithIamge:self.image WithSize:self.size WithDocument:self.document WithView:self.pdfView];
+        [self addChildViewController:self.headefooterControl];
+        [self.view addSubview:self.headefooterControl.view];
+        [self.navigationController pushViewController:self.headefooterControl animated:NO];
        }];
     //seeting bates action
     UIAlertAction *settingBatesAction = [UIAlertAction actionWithTitle:@"Setting Bates" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
@@ -86,6 +85,25 @@
     [alertController addAction:settingBatesAction];
     [alertController addAction:cancelAction];
     [self presentViewController:alertController animated:YES completion:nil];
+    self.pdfView = self.headefooterControl.pdfView;
+    [self.view addSubview:self.pdfView];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(getModel:) name:@"getSettingModel" object:nil];
+}
+
+- (void)getModel:(NSNotification *)text {
+    self.modelData = self.headefooterControl.modelData;
+    self.headerFooter = [self.document headerFooter];
+    self.headerFooter.pageString = @"1";
+    [self.headerFooter setText:@"1" atIndex:self.modelData.fontPosition];
+    [self.headerFooter setTextColor:self.modelData.fontColor atIndex:self.modelData.fontPosition];
+    [self.headerFooter update];
+    NSURL *url = [NSURL fileURLWithPath:self.path];
+    [self.document writeToURL:url];
+    _document = [[CPDFDocument alloc] initWithURL:url];
+    _pdfView = [[CPDFView alloc] initWithFrame:self.view.bounds];
+    _pdfView.document = _document;
+    _pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+   [self.view addSubview:_pdfView];
 }
 
 @end

+ 0 - 16
PDFViewer/Controller/HeaderFooterAddView.h

@@ -1,16 +0,0 @@
-//
-//  HeaderFooterAddView.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/16.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface HeaderFooterAddView : UIView
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 20
PDFViewer/Controller/HeaderFooterAddView.m

@@ -1,20 +0,0 @@
-//
-//  HeaderFooterAddView.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/16.
-//
-
-#import "HeaderFooterAddView.h"
-
-@implementation HeaderFooterAddView
-
-/*
-// Only override drawRect: if you perform custom drawing.
-// An empty implementation adversely affects performance during animation.
-- (void)drawRect:(CGRect)rect {
-    // Drawing code
-}
-*/
-
-@end

+ 0 - 16
PDFViewer/Controller/HeaderFooterAlertViewController.h

@@ -1,16 +0,0 @@
-//
-//  HeaderFooterAlertViewController.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/16.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface HeaderFooterAlertViewController : UIViewController
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 31
PDFViewer/Controller/HeaderFooterAlertViewController.m

@@ -1,31 +0,0 @@
-//
-//  HeaderFooterAlertViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/16.
-//
-
-#import "HeaderFooterAlertViewController.h"
-
-@interface HeaderFooterAlertViewController ()
-
-@end
-
-@implementation HeaderFooterAlertViewController
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-}
-
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
-
-@end

+ 0 - 31
PDFViewer/Controller/HeaderFooterDeleteViewController.m

@@ -1,31 +0,0 @@
-//
-//  HeaderFooterDeleteViewController.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/17.
-//
-
-#import "HeaderFooterDeleteViewController.h"
-
-@interface HeaderFooterDeleteViewController ()
-
-@end
-
-@implementation HeaderFooterDeleteViewController
-
-- (void)viewDidLoad {
-    [super viewDidLoad];
-    // Do any additional setup after loading the view.
-}
-
-/*
-#pragma mark - Navigation
-
-// In a storyboard-based application, you will often want to do a little preparation before navigation
-- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
-    // Get the new view controller using [segue destinationViewController].
-    // Pass the selected object to the new view controller.
-}
-*/
-
-@end

+ 26 - 0
PDFViewer/Masonry/Info.plist

@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>en</string>
+	<key>CFBundleExecutable</key>
+	<string>$(EXECUTABLE_NAME)</string>
+	<key>CFBundleIdentifier</key>
+	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>6.0</string>
+	<key>CFBundleName</key>
+	<string>$(PRODUCT_NAME)</string>
+	<key>CFBundlePackageType</key>
+	<string>FMWK</string>
+	<key>CFBundleShortVersionString</key>
+	<string>1.0</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>$(CURRENT_PROJECT_VERSION)</string>
+	<key>NSPrincipalClass</key>
+	<string></string>
+</dict>
+</plist>

+ 26 - 0
PDFViewer/Masonry/MASCompositeConstraint.h

@@ -0,0 +1,26 @@
+//
+//  MASCompositeConstraint.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 21/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASConstraint.h"
+#import "MASUtilities.h"
+
+/**
+ *	A group of MASConstraint objects
+ */
+@interface MASCompositeConstraint : MASConstraint
+
+/**
+ *	Creates a composite with a predefined array of children
+ *
+ *	@param	children	child MASConstraints
+ *
+ *	@return	a composite constraint
+ */
+- (id)initWithChildren:(NSArray *)children;
+
+@end

+ 183 - 0
PDFViewer/Masonry/MASCompositeConstraint.m

@@ -0,0 +1,183 @@
+//
+//  MASCompositeConstraint.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 21/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASCompositeConstraint.h"
+#import "MASConstraint+Private.h"
+
+@interface MASCompositeConstraint () <MASConstraintDelegate>
+
+@property (nonatomic, strong) id mas_key;
+@property (nonatomic, strong) NSMutableArray *childConstraints;
+
+@end
+
+@implementation MASCompositeConstraint
+
+- (id)initWithChildren:(NSArray *)children {
+    self = [super init];
+    if (!self) return nil;
+
+    _childConstraints = [children mutableCopy];
+    for (MASConstraint *constraint in _childConstraints) {
+        constraint.delegate = self;
+    }
+
+    return self;
+}
+
+#pragma mark - MASConstraintDelegate
+
+- (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
+    NSUInteger index = [self.childConstraints indexOfObject:constraint];
+    NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
+    [self.childConstraints replaceObjectAtIndex:index withObject:replacementConstraint];
+}
+
+- (MASConstraint *)constraint:(MASConstraint __unused *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    id<MASConstraintDelegate> strongDelegate = self.delegate;
+    MASConstraint *newConstraint = [strongDelegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
+    newConstraint.delegate = self;
+    [self.childConstraints addObject:newConstraint];
+    return newConstraint;
+}
+
+#pragma mark - NSLayoutConstraint multiplier proxies 
+
+- (MASConstraint * (^)(CGFloat))multipliedBy {
+    return ^id(CGFloat multiplier) {
+        for (MASConstraint *constraint in self.childConstraints) {
+            constraint.multipliedBy(multiplier);
+        }
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(CGFloat))dividedBy {
+    return ^id(CGFloat divider) {
+        for (MASConstraint *constraint in self.childConstraints) {
+            constraint.dividedBy(divider);
+        }
+        return self;
+    };
+}
+
+#pragma mark - MASLayoutPriority proxy
+
+- (MASConstraint * (^)(MASLayoutPriority))priority {
+    return ^id(MASLayoutPriority priority) {
+        for (MASConstraint *constraint in self.childConstraints) {
+            constraint.priority(priority);
+        }
+        return self;
+    };
+}
+
+#pragma mark - NSLayoutRelation proxy
+
+- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
+    return ^id(id attr, NSLayoutRelation relation) {
+        for (MASConstraint *constraint in self.childConstraints.copy) {
+            constraint.equalToWithRelation(attr, relation);
+        }
+        return self;
+    };
+}
+
+#pragma mark - attribute chaining
+
+- (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    [self constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
+    return self;
+}
+
+#pragma mark - Animator proxy
+
+#if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
+
+- (MASConstraint *)animator {
+    for (MASConstraint *constraint in self.childConstraints) {
+        [constraint animator];
+    }
+    return self;
+}
+
+#endif
+
+#pragma mark - debug helpers
+
+- (MASConstraint * (^)(id))key {
+    return ^id(id key) {
+        self.mas_key = key;
+        int i = 0;
+        for (MASConstraint *constraint in self.childConstraints) {
+            constraint.key([NSString stringWithFormat:@"%@[%d]", key, i++]);
+        }
+        return self;
+    };
+}
+
+#pragma mark - NSLayoutConstraint constant setters
+
+- (void)setInsets:(MASEdgeInsets)insets {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.insets = insets;
+    }
+}
+
+- (void)setInset:(CGFloat)inset {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.inset = inset;
+    }
+}
+
+- (void)setOffset:(CGFloat)offset {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.offset = offset;
+    }
+}
+
+- (void)setSizeOffset:(CGSize)sizeOffset {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.sizeOffset = sizeOffset;
+    }
+}
+
+- (void)setCenterOffset:(CGPoint)centerOffset {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.centerOffset = centerOffset;
+    }
+}
+
+#pragma mark - MASConstraint
+
+- (void)activate {
+    for (MASConstraint *constraint in self.childConstraints) {
+        [constraint activate];
+    }
+}
+
+- (void)deactivate {
+    for (MASConstraint *constraint in self.childConstraints) {
+        [constraint deactivate];
+    }
+}
+
+- (void)install {
+    for (MASConstraint *constraint in self.childConstraints) {
+        constraint.updateExisting = self.updateExisting;
+        [constraint install];
+    }
+}
+
+- (void)uninstall {
+    for (MASConstraint *constraint in self.childConstraints) {
+        [constraint uninstall];
+    }
+}
+
+@end

+ 66 - 0
PDFViewer/Masonry/MASConstraint+Private.h

@@ -0,0 +1,66 @@
+//
+//  MASConstraint+Private.h
+//  Masonry
+//
+//  Created by Nick Tymchenko on 29/04/14.
+//  Copyright (c) 2014 cloudling. All rights reserved.
+//
+
+#import "MASConstraint.h"
+
+@protocol MASConstraintDelegate;
+
+
+@interface MASConstraint ()
+
+/**
+ *  Whether or not to check for an existing constraint instead of adding constraint
+ */
+@property (nonatomic, assign) BOOL updateExisting;
+
+/**
+ *	Usually MASConstraintMaker but could be a parent MASConstraint
+ */
+@property (nonatomic, weak) id<MASConstraintDelegate> delegate;
+
+/**
+ *  Based on a provided value type, is equal to calling:
+ *  NSNumber - setOffset:
+ *  NSValue with CGPoint - setPointOffset:
+ *  NSValue with CGSize - setSizeOffset:
+ *  NSValue with MASEdgeInsets - setInsets:
+ */
+- (void)setLayoutConstantWithValue:(NSValue *)value;
+
+@end
+
+
+@interface MASConstraint (Abstract)
+
+/**
+ *	Sets the constraint relation to given NSLayoutRelation
+ *  returns a block which accepts one of the following:
+ *    MASViewAttribute, UIView, NSValue, NSArray
+ *  see readme for more details.
+ */
+- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation;
+
+/**
+ *	Override to set a custom chaining behaviour
+ */
+- (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
+
+@end
+
+
+@protocol MASConstraintDelegate <NSObject>
+
+/**
+ *	Notifies the delegate when the constraint needs to be replaced with another constraint. For example
+ *  A MASViewConstraint may turn into a MASCompositeConstraint when an array is passed to one of the equality blocks
+ */
+- (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint;
+
+- (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute;
+
+@end

+ 268 - 0
PDFViewer/Masonry/MASConstraint.h

@@ -0,0 +1,268 @@
+//
+//  MASConstraint.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 22/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASUtilities.h"
+
+/**
+ *	Enables Constraints to be created with chainable syntax
+ *  Constraint can represent single NSLayoutConstraint (MASViewConstraint) 
+ *  or a group of NSLayoutConstraints (MASComposisteConstraint)
+ */
+@interface MASConstraint : NSObject
+
+// Chaining Support
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
+ */
+- (MASConstraint * (^)(MASEdgeInsets insets))insets;
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
+ */
+- (MASConstraint * (^)(CGFloat inset))inset;
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeWidth, NSLayoutAttributeHeight
+ */
+- (MASConstraint * (^)(CGSize offset))sizeOffset;
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
+ */
+- (MASConstraint * (^)(CGPoint offset))centerOffset;
+
+/**
+ *	Modifies the NSLayoutConstraint constant
+ */
+- (MASConstraint * (^)(CGFloat offset))offset;
+
+/**
+ *  Modifies the NSLayoutConstraint constant based on a value type
+ */
+- (MASConstraint * (^)(NSValue *value))valueOffset;
+
+/**
+ *	Sets the NSLayoutConstraint multiplier property
+ */
+- (MASConstraint * (^)(CGFloat multiplier))multipliedBy;
+
+/**
+ *	Sets the NSLayoutConstraint multiplier to 1.0/dividedBy
+ */
+- (MASConstraint * (^)(CGFloat divider))dividedBy;
+
+/**
+ *	Sets the NSLayoutConstraint priority to a float or MASLayoutPriority
+ */
+- (MASConstraint * (^)(MASLayoutPriority priority))priority;
+
+/**
+ *	Sets the NSLayoutConstraint priority to MASLayoutPriorityLow
+ */
+- (MASConstraint * (^)(void))priorityLow;
+
+/**
+ *	Sets the NSLayoutConstraint priority to MASLayoutPriorityMedium
+ */
+- (MASConstraint * (^)(void))priorityMedium;
+
+/**
+ *	Sets the NSLayoutConstraint priority to MASLayoutPriorityHigh
+ */
+- (MASConstraint * (^)(void))priorityHigh;
+
+/**
+ *	Sets the constraint relation to NSLayoutRelationEqual
+ *  returns a block which accepts one of the following:
+ *    MASViewAttribute, UIView, NSValue, NSArray
+ *  see readme for more details.
+ */
+- (MASConstraint * (^)(id attr))equalTo;
+
+/**
+ *	Sets the constraint relation to NSLayoutRelationGreaterThanOrEqual
+ *  returns a block which accepts one of the following:
+ *    MASViewAttribute, UIView, NSValue, NSArray
+ *  see readme for more details.
+ */
+- (MASConstraint * (^)(id attr))greaterThanOrEqualTo;
+
+/**
+ *	Sets the constraint relation to NSLayoutRelationLessThanOrEqual
+ *  returns a block which accepts one of the following:
+ *    MASViewAttribute, UIView, NSValue, NSArray
+ *  see readme for more details.
+ */
+- (MASConstraint * (^)(id attr))lessThanOrEqualTo;
+
+/**
+ *	Optional semantic property which has no effect but improves the readability of constraint
+ */
+- (MASConstraint *)with;
+
+/**
+ *	Optional semantic property which has no effect but improves the readability of constraint
+ */
+- (MASConstraint *)and;
+
+/**
+ *	Creates a new MASCompositeConstraint with the called attribute and reciever
+ */
+- (MASConstraint *)left;
+- (MASConstraint *)top;
+- (MASConstraint *)right;
+- (MASConstraint *)bottom;
+- (MASConstraint *)leading;
+- (MASConstraint *)trailing;
+- (MASConstraint *)width;
+- (MASConstraint *)height;
+- (MASConstraint *)centerX;
+- (MASConstraint *)centerY;
+- (MASConstraint *)baseline;
+
+- (MASConstraint *)firstBaseline;
+- (MASConstraint *)lastBaseline;
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+- (MASConstraint *)leftMargin;
+- (MASConstraint *)rightMargin;
+- (MASConstraint *)topMargin;
+- (MASConstraint *)bottomMargin;
+- (MASConstraint *)leadingMargin;
+- (MASConstraint *)trailingMargin;
+- (MASConstraint *)centerXWithinMargins;
+- (MASConstraint *)centerYWithinMargins;
+
+#endif
+
+
+/**
+ *	Sets the constraint debug name
+ */
+- (MASConstraint * (^)(id key))key;
+
+// NSLayoutConstraint constant Setters
+// for use outside of mas_updateConstraints/mas_makeConstraints blocks
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
+ */
+- (void)setInsets:(MASEdgeInsets)insets;
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeTop, NSLayoutAttributeLeft, NSLayoutAttributeBottom, NSLayoutAttributeRight
+ */
+- (void)setInset:(CGFloat)inset;
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeWidth, NSLayoutAttributeHeight
+ */
+- (void)setSizeOffset:(CGSize)sizeOffset;
+
+/**
+ *	Modifies the NSLayoutConstraint constant,
+ *  only affects MASConstraints in which the first item's NSLayoutAttribute is one of the following
+ *  NSLayoutAttributeCenterX, NSLayoutAttributeCenterY
+ */
+- (void)setCenterOffset:(CGPoint)centerOffset;
+
+/**
+ *	Modifies the NSLayoutConstraint constant
+ */
+- (void)setOffset:(CGFloat)offset;
+
+
+// NSLayoutConstraint Installation support
+
+#if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
+/**
+ *  Whether or not to go through the animator proxy when modifying the constraint
+ */
+@property (nonatomic, copy, readonly) MASConstraint *animator;
+#endif
+
+/**
+ *  Activates an NSLayoutConstraint if it's supported by an OS. 
+ *  Invokes install otherwise.
+ */
+- (void)activate;
+
+/**
+ *  Deactivates previously installed/activated NSLayoutConstraint.
+ */
+- (void)deactivate;
+
+/**
+ *	Creates a NSLayoutConstraint and adds it to the appropriate view.
+ */
+- (void)install;
+
+/**
+ *	Removes previously installed NSLayoutConstraint
+ */
+- (void)uninstall;
+
+@end
+
+
+/**
+ *  Convenience auto-boxing macros for MASConstraint methods.
+ *
+ *  Defining MAS_SHORTHAND_GLOBALS will turn on auto-boxing for default syntax.
+ *  A potential drawback of this is that the unprefixed macros will appear in global scope.
+ */
+#define mas_equalTo(...)                 equalTo(MASBoxValue((__VA_ARGS__)))
+#define mas_greaterThanOrEqualTo(...)    greaterThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
+#define mas_lessThanOrEqualTo(...)       lessThanOrEqualTo(MASBoxValue((__VA_ARGS__)))
+
+#define mas_offset(...)                  valueOffset(MASBoxValue((__VA_ARGS__)))
+
+
+#ifdef MAS_SHORTHAND_GLOBALS
+
+#define equalTo(...)                     mas_equalTo(__VA_ARGS__)
+#define greaterThanOrEqualTo(...)        mas_greaterThanOrEqualTo(__VA_ARGS__)
+#define lessThanOrEqualTo(...)           mas_lessThanOrEqualTo(__VA_ARGS__)
+
+#define offset(...)                      mas_offset(__VA_ARGS__)
+
+#endif
+
+
+@interface MASConstraint (AutoboxingSupport)
+
+/**
+ *  Aliases to corresponding relation methods (for shorthand macros)
+ *  Also needed to aid autocompletion
+ */
+- (MASConstraint * (^)(id attr))mas_equalTo;
+- (MASConstraint * (^)(id attr))mas_greaterThanOrEqualTo;
+- (MASConstraint * (^)(id attr))mas_lessThanOrEqualTo;
+
+/**
+ *  A dummy method to aid autocompletion
+ */
+- (MASConstraint * (^)(id offset))mas_offset;
+
+@end

+ 297 - 0
PDFViewer/Masonry/MASConstraint.m

@@ -0,0 +1,297 @@
+//
+//  MASConstraint.m
+//  Masonry
+//
+//  Created by Nick Tymchenko on 1/20/14.
+//
+
+#import "MASConstraint.h"
+#import "MASConstraint+Private.h"
+
+#define MASMethodNotImplemented() \
+    @throw [NSException exceptionWithName:NSInternalInconsistencyException \
+                                   reason:[NSString stringWithFormat:@"You must override %@ in a subclass.", NSStringFromSelector(_cmd)] \
+                                 userInfo:nil]
+
+@implementation MASConstraint
+
+#pragma mark - Init
+
+- (id)init {
+	NSAssert(![self isMemberOfClass:[MASConstraint class]], @"MASConstraint is an abstract class, you should not instantiate it directly.");
+	return [super init];
+}
+
+#pragma mark - NSLayoutRelation proxies
+
+- (MASConstraint * (^)(id))equalTo {
+    return ^id(id attribute) {
+        return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
+    };
+}
+
+- (MASConstraint * (^)(id))mas_equalTo {
+    return ^id(id attribute) {
+        return self.equalToWithRelation(attribute, NSLayoutRelationEqual);
+    };
+}
+
+- (MASConstraint * (^)(id))greaterThanOrEqualTo {
+    return ^id(id attribute) {
+        return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
+    };
+}
+
+- (MASConstraint * (^)(id))mas_greaterThanOrEqualTo {
+    return ^id(id attribute) {
+        return self.equalToWithRelation(attribute, NSLayoutRelationGreaterThanOrEqual);
+    };
+}
+
+- (MASConstraint * (^)(id))lessThanOrEqualTo {
+    return ^id(id attribute) {
+        return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
+    };
+}
+
+- (MASConstraint * (^)(id))mas_lessThanOrEqualTo {
+    return ^id(id attribute) {
+        return self.equalToWithRelation(attribute, NSLayoutRelationLessThanOrEqual);
+    };
+}
+
+#pragma mark - MASLayoutPriority proxies
+
+- (MASConstraint * (^)(void))priorityLow {
+    return ^id{
+        self.priority(MASLayoutPriorityDefaultLow);
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(void))priorityMedium {
+    return ^id{
+        self.priority(MASLayoutPriorityDefaultMedium);
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(void))priorityHigh {
+    return ^id{
+        self.priority(MASLayoutPriorityDefaultHigh);
+        return self;
+    };
+}
+
+#pragma mark - NSLayoutConstraint constant proxies
+
+- (MASConstraint * (^)(MASEdgeInsets))insets {
+    return ^id(MASEdgeInsets insets){
+        self.insets = insets;
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(CGFloat))inset {
+    return ^id(CGFloat inset){
+        self.inset = inset;
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(CGSize))sizeOffset {
+    return ^id(CGSize offset) {
+        self.sizeOffset = offset;
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(CGPoint))centerOffset {
+    return ^id(CGPoint offset) {
+        self.centerOffset = offset;
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(CGFloat))offset {
+    return ^id(CGFloat offset){
+        self.offset = offset;
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(NSValue *value))valueOffset {
+    return ^id(NSValue *offset) {
+        NSAssert([offset isKindOfClass:NSValue.class], @"expected an NSValue offset, got: %@", offset);
+        [self setLayoutConstantWithValue:offset];
+        return self;
+    };
+}
+
+- (MASConstraint * (^)(id offset))mas_offset {
+    // Will never be called due to macro
+    return nil;
+}
+
+#pragma mark - NSLayoutConstraint constant setter
+
+- (void)setLayoutConstantWithValue:(NSValue *)value {
+    if ([value isKindOfClass:NSNumber.class]) {
+        self.offset = [(NSNumber *)value doubleValue];
+    } else if (strcmp(value.objCType, @encode(CGPoint)) == 0) {
+        CGPoint point;
+        [value getValue:&point];
+        self.centerOffset = point;
+    } else if (strcmp(value.objCType, @encode(CGSize)) == 0) {
+        CGSize size;
+        [value getValue:&size];
+        self.sizeOffset = size;
+    } else if (strcmp(value.objCType, @encode(MASEdgeInsets)) == 0) {
+        MASEdgeInsets insets;
+        [value getValue:&insets];
+        self.insets = insets;
+    } else {
+        NSAssert(NO, @"attempting to set layout constant with unsupported value: %@", value);
+    }
+}
+
+#pragma mark - Semantic properties
+
+- (MASConstraint *)with {
+    return self;
+}
+
+- (MASConstraint *)and {
+    return self;
+}
+
+#pragma mark - Chaining
+
+- (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute __unused)layoutAttribute {
+    MASMethodNotImplemented();
+}
+
+- (MASConstraint *)left {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
+}
+
+- (MASConstraint *)top {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
+}
+
+- (MASConstraint *)right {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
+}
+
+- (MASConstraint *)bottom {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
+}
+
+- (MASConstraint *)leading {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
+}
+
+- (MASConstraint *)trailing {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
+}
+
+- (MASConstraint *)width {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
+}
+
+- (MASConstraint *)height {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
+}
+
+- (MASConstraint *)centerX {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
+}
+
+- (MASConstraint *)centerY {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
+}
+
+- (MASConstraint *)baseline {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
+}
+
+- (MASConstraint *)firstBaseline {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline];
+}
+- (MASConstraint *)lastBaseline {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline];
+}
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+- (MASConstraint *)leftMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
+}
+
+- (MASConstraint *)rightMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
+}
+
+- (MASConstraint *)topMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
+}
+
+- (MASConstraint *)bottomMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
+}
+
+- (MASConstraint *)leadingMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
+}
+
+- (MASConstraint *)trailingMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
+}
+
+- (MASConstraint *)centerXWithinMargins {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
+}
+
+- (MASConstraint *)centerYWithinMargins {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
+}
+
+#endif
+
+#pragma mark - Abstract
+
+- (MASConstraint * (^)(CGFloat multiplier))multipliedBy { MASMethodNotImplemented(); }
+
+- (MASConstraint * (^)(CGFloat divider))dividedBy { MASMethodNotImplemented(); }
+
+- (MASConstraint * (^)(MASLayoutPriority priority))priority { MASMethodNotImplemented(); }
+
+- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation { MASMethodNotImplemented(); }
+
+- (MASConstraint * (^)(id key))key { MASMethodNotImplemented(); }
+
+- (void)setInsets:(MASEdgeInsets __unused)insets { MASMethodNotImplemented(); }
+
+- (void)setInset:(CGFloat __unused)inset { MASMethodNotImplemented(); }
+
+- (void)setSizeOffset:(CGSize __unused)sizeOffset { MASMethodNotImplemented(); }
+
+- (void)setCenterOffset:(CGPoint __unused)centerOffset { MASMethodNotImplemented(); }
+
+- (void)setOffset:(CGFloat __unused)offset { MASMethodNotImplemented(); }
+
+#if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
+
+- (MASConstraint *)animator { MASMethodNotImplemented(); }
+
+#endif
+
+- (void)activate { MASMethodNotImplemented(); }
+
+- (void)deactivate { MASMethodNotImplemented(); }
+
+- (void)install { MASMethodNotImplemented(); }
+
+- (void)uninstall { MASMethodNotImplemented(); }
+
+@end

+ 138 - 0
PDFViewer/Masonry/MASConstraintMaker.h

@@ -0,0 +1,138 @@
+//
+//  MASConstraintMaker.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASConstraint.h"
+#import "MASUtilities.h"
+
+typedef NS_OPTIONS(NSInteger, MASAttribute) {
+    MASAttributeLeft = 1 << NSLayoutAttributeLeft,
+    MASAttributeRight = 1 << NSLayoutAttributeRight,
+    MASAttributeTop = 1 << NSLayoutAttributeTop,
+    MASAttributeBottom = 1 << NSLayoutAttributeBottom,
+    MASAttributeLeading = 1 << NSLayoutAttributeLeading,
+    MASAttributeTrailing = 1 << NSLayoutAttributeTrailing,
+    MASAttributeWidth = 1 << NSLayoutAttributeWidth,
+    MASAttributeHeight = 1 << NSLayoutAttributeHeight,
+    MASAttributeCenterX = 1 << NSLayoutAttributeCenterX,
+    MASAttributeCenterY = 1 << NSLayoutAttributeCenterY,
+    MASAttributeBaseline = 1 << NSLayoutAttributeBaseline,
+
+    MASAttributeFirstBaseline = 1 << NSLayoutAttributeFirstBaseline,
+    MASAttributeLastBaseline = 1 << NSLayoutAttributeLastBaseline,
+    
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+    
+    MASAttributeLeftMargin = 1 << NSLayoutAttributeLeftMargin,
+    MASAttributeRightMargin = 1 << NSLayoutAttributeRightMargin,
+    MASAttributeTopMargin = 1 << NSLayoutAttributeTopMargin,
+    MASAttributeBottomMargin = 1 << NSLayoutAttributeBottomMargin,
+    MASAttributeLeadingMargin = 1 << NSLayoutAttributeLeadingMargin,
+    MASAttributeTrailingMargin = 1 << NSLayoutAttributeTrailingMargin,
+    MASAttributeCenterXWithinMargins = 1 << NSLayoutAttributeCenterXWithinMargins,
+    MASAttributeCenterYWithinMargins = 1 << NSLayoutAttributeCenterYWithinMargins,
+
+#endif
+    
+};
+
+/**
+ *  Provides factory methods for creating MASConstraints.
+ *  Constraints are collected until they are ready to be installed
+ *
+ */
+@interface MASConstraintMaker : NSObject
+
+/**
+ *	The following properties return a new MASViewConstraint
+ *  with the first item set to the makers associated view and the appropriate MASViewAttribute
+ */
+@property (nonatomic, strong, readonly) MASConstraint *left;
+@property (nonatomic, strong, readonly) MASConstraint *top;
+@property (nonatomic, strong, readonly) MASConstraint *right;
+@property (nonatomic, strong, readonly) MASConstraint *bottom;
+@property (nonatomic, strong, readonly) MASConstraint *leading;
+@property (nonatomic, strong, readonly) MASConstraint *trailing;
+@property (nonatomic, strong, readonly) MASConstraint *width;
+@property (nonatomic, strong, readonly) MASConstraint *height;
+@property (nonatomic, strong, readonly) MASConstraint *centerX;
+@property (nonatomic, strong, readonly) MASConstraint *centerY;
+@property (nonatomic, strong, readonly) MASConstraint *baseline;
+
+@property (nonatomic, strong, readonly) MASConstraint *firstBaseline;
+@property (nonatomic, strong, readonly) MASConstraint *lastBaseline;
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+@property (nonatomic, strong, readonly) MASConstraint *leftMargin;
+@property (nonatomic, strong, readonly) MASConstraint *rightMargin;
+@property (nonatomic, strong, readonly) MASConstraint *topMargin;
+@property (nonatomic, strong, readonly) MASConstraint *bottomMargin;
+@property (nonatomic, strong, readonly) MASConstraint *leadingMargin;
+@property (nonatomic, strong, readonly) MASConstraint *trailingMargin;
+@property (nonatomic, strong, readonly) MASConstraint *centerXWithinMargins;
+@property (nonatomic, strong, readonly) MASConstraint *centerYWithinMargins;
+
+#endif
+
+/**
+ *  Returns a block which creates a new MASCompositeConstraint with the first item set
+ *  to the makers associated view and children corresponding to the set bits in the
+ *  MASAttribute parameter. Combine multiple attributes via binary-or.
+ */
+@property (nonatomic, strong, readonly) MASConstraint *(^attributes)(MASAttribute attrs);
+
+/**
+ *	Creates a MASCompositeConstraint with type MASCompositeConstraintTypeEdges
+ *  which generates the appropriate MASViewConstraint children (top, left, bottom, right)
+ *  with the first item set to the makers associated view
+ */
+@property (nonatomic, strong, readonly) MASConstraint *edges;
+
+/**
+ *	Creates a MASCompositeConstraint with type MASCompositeConstraintTypeSize
+ *  which generates the appropriate MASViewConstraint children (width, height)
+ *  with the first item set to the makers associated view
+ */
+@property (nonatomic, strong, readonly) MASConstraint *size;
+
+/**
+ *	Creates a MASCompositeConstraint with type MASCompositeConstraintTypeCenter
+ *  which generates the appropriate MASViewConstraint children (centerX, centerY)
+ *  with the first item set to the makers associated view
+ */
+@property (nonatomic, strong, readonly) MASConstraint *center;
+
+/**
+ *  Whether or not to check for an existing constraint instead of adding constraint
+ */
+@property (nonatomic, assign) BOOL updateExisting;
+
+/**
+ *  Whether or not to remove existing constraints prior to installing
+ */
+@property (nonatomic, assign) BOOL removeExisting;
+
+/**
+ *	initialises the maker with a default view
+ *
+ *	@param	view	any MASConstraint are created with this view as the first item
+ *
+ *	@return	a new MASConstraintMaker
+ */
+- (id)initWithView:(MAS_VIEW *)view;
+
+/**
+ *	Calls install method on any MASConstraints which have been created by this maker
+ *
+ *	@return	an array of all the installed MASConstraints
+ */
+- (NSArray *)install;
+
+- (MASConstraint * (^)(dispatch_block_t))group;
+
+@end

+ 261 - 0
PDFViewer/Masonry/MASConstraintMaker.m

@@ -0,0 +1,261 @@
+//
+//  MASConstraintMaker.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASConstraintMaker.h"
+#import "MASViewConstraint.h"
+#import "MASCompositeConstraint.h"
+#import "MASConstraint+Private.h"
+#import "MASViewAttribute.h"
+#import "View+MASAdditions.h"
+
+@interface MASConstraintMaker () <MASConstraintDelegate>
+
+@property (nonatomic, weak) MAS_VIEW *view;
+@property (nonatomic, strong) NSMutableArray *constraints;
+
+@end
+
+@implementation MASConstraintMaker
+
+- (id)initWithView:(MAS_VIEW *)view {
+    self = [super init];
+    if (!self) return nil;
+    
+    self.view = view;
+    self.constraints = NSMutableArray.new;
+    
+    return self;
+}
+
+- (NSArray *)install {
+    if (self.removeExisting) {
+        NSArray *installedConstraints = [MASViewConstraint installedConstraintsForView:self.view];
+        for (MASConstraint *constraint in installedConstraints) {
+            [constraint uninstall];
+        }
+    }
+    NSArray *constraints = self.constraints.copy;
+    for (MASConstraint *constraint in constraints) {
+        constraint.updateExisting = self.updateExisting;
+        [constraint install];
+    }
+    [self.constraints removeAllObjects];
+    return constraints;
+}
+
+#pragma mark - MASConstraintDelegate
+
+- (void)constraint:(MASConstraint *)constraint shouldBeReplacedWithConstraint:(MASConstraint *)replacementConstraint {
+    NSUInteger index = [self.constraints indexOfObject:constraint];
+    NSAssert(index != NSNotFound, @"Could not find constraint %@", constraint);
+    [self.constraints replaceObjectAtIndex:index withObject:replacementConstraint];
+}
+
+- (MASConstraint *)constraint:(MASConstraint *)constraint addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    MASViewAttribute *viewAttribute = [[MASViewAttribute alloc] initWithView:self.view layoutAttribute:layoutAttribute];
+    MASViewConstraint *newConstraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:viewAttribute];
+    if ([constraint isKindOfClass:MASViewConstraint.class]) {
+        //replace with composite constraint
+        NSArray *children = @[constraint, newConstraint];
+        MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children];
+        compositeConstraint.delegate = self;
+        [self constraint:constraint shouldBeReplacedWithConstraint:compositeConstraint];
+        return compositeConstraint;
+    }
+    if (!constraint) {
+        newConstraint.delegate = self;
+        [self.constraints addObject:newConstraint];
+    }
+    return newConstraint;
+}
+
+- (MASConstraint *)addConstraintWithAttributes:(MASAttribute)attrs {
+    __unused MASAttribute anyAttribute = (MASAttributeLeft | MASAttributeRight | MASAttributeTop | MASAttributeBottom | MASAttributeLeading
+                                          | MASAttributeTrailing | MASAttributeWidth | MASAttributeHeight | MASAttributeCenterX
+                                          | MASAttributeCenterY | MASAttributeBaseline
+                                          | MASAttributeFirstBaseline | MASAttributeLastBaseline
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+                                          | MASAttributeLeftMargin | MASAttributeRightMargin | MASAttributeTopMargin | MASAttributeBottomMargin
+                                          | MASAttributeLeadingMargin | MASAttributeTrailingMargin | MASAttributeCenterXWithinMargins
+                                          | MASAttributeCenterYWithinMargins
+#endif
+                                          );
+    
+    NSAssert((attrs & anyAttribute) != 0, @"You didn't pass any attribute to make.attributes(...)");
+    
+    NSMutableArray *attributes = [NSMutableArray array];
+    
+    if (attrs & MASAttributeLeft) [attributes addObject:self.view.mas_left];
+    if (attrs & MASAttributeRight) [attributes addObject:self.view.mas_right];
+    if (attrs & MASAttributeTop) [attributes addObject:self.view.mas_top];
+    if (attrs & MASAttributeBottom) [attributes addObject:self.view.mas_bottom];
+    if (attrs & MASAttributeLeading) [attributes addObject:self.view.mas_leading];
+    if (attrs & MASAttributeTrailing) [attributes addObject:self.view.mas_trailing];
+    if (attrs & MASAttributeWidth) [attributes addObject:self.view.mas_width];
+    if (attrs & MASAttributeHeight) [attributes addObject:self.view.mas_height];
+    if (attrs & MASAttributeCenterX) [attributes addObject:self.view.mas_centerX];
+    if (attrs & MASAttributeCenterY) [attributes addObject:self.view.mas_centerY];
+    if (attrs & MASAttributeBaseline) [attributes addObject:self.view.mas_baseline];
+    if (attrs & MASAttributeFirstBaseline) [attributes addObject:self.view.mas_firstBaseline];
+    if (attrs & MASAttributeLastBaseline) [attributes addObject:self.view.mas_lastBaseline];
+    
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+    
+    if (attrs & MASAttributeLeftMargin) [attributes addObject:self.view.mas_leftMargin];
+    if (attrs & MASAttributeRightMargin) [attributes addObject:self.view.mas_rightMargin];
+    if (attrs & MASAttributeTopMargin) [attributes addObject:self.view.mas_topMargin];
+    if (attrs & MASAttributeBottomMargin) [attributes addObject:self.view.mas_bottomMargin];
+    if (attrs & MASAttributeLeadingMargin) [attributes addObject:self.view.mas_leadingMargin];
+    if (attrs & MASAttributeTrailingMargin) [attributes addObject:self.view.mas_trailingMargin];
+    if (attrs & MASAttributeCenterXWithinMargins) [attributes addObject:self.view.mas_centerXWithinMargins];
+    if (attrs & MASAttributeCenterYWithinMargins) [attributes addObject:self.view.mas_centerYWithinMargins];
+    
+#endif
+    
+    NSMutableArray *children = [NSMutableArray arrayWithCapacity:attributes.count];
+    
+    for (MASViewAttribute *a in attributes) {
+        [children addObject:[[MASViewConstraint alloc] initWithFirstViewAttribute:a]];
+    }
+    
+    MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children];
+    constraint.delegate = self;
+    [self.constraints addObject:constraint];
+    return constraint;
+}
+
+#pragma mark - standard Attributes
+
+- (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    return [self constraint:nil addConstraintWithLayoutAttribute:layoutAttribute];
+}
+
+- (MASConstraint *)left {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeft];
+}
+
+- (MASConstraint *)top {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTop];
+}
+
+- (MASConstraint *)right {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRight];
+}
+
+- (MASConstraint *)bottom {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottom];
+}
+
+- (MASConstraint *)leading {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeading];
+}
+
+- (MASConstraint *)trailing {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailing];
+}
+
+- (MASConstraint *)width {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeWidth];
+}
+
+- (MASConstraint *)height {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeHeight];
+}
+
+- (MASConstraint *)centerX {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterX];
+}
+
+- (MASConstraint *)centerY {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterY];
+}
+
+- (MASConstraint *)baseline {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBaseline];
+}
+
+- (MASConstraint *(^)(MASAttribute))attributes {
+    return ^(MASAttribute attrs){
+        return [self addConstraintWithAttributes:attrs];
+    };
+}
+
+- (MASConstraint *)firstBaseline {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeFirstBaseline];
+}
+
+- (MASConstraint *)lastBaseline {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLastBaseline];
+}
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+- (MASConstraint *)leftMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeftMargin];
+}
+
+- (MASConstraint *)rightMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeRightMargin];
+}
+
+- (MASConstraint *)topMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTopMargin];
+}
+
+- (MASConstraint *)bottomMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeBottomMargin];
+}
+
+- (MASConstraint *)leadingMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeLeadingMargin];
+}
+
+- (MASConstraint *)trailingMargin {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeTrailingMargin];
+}
+
+- (MASConstraint *)centerXWithinMargins {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterXWithinMargins];
+}
+
+- (MASConstraint *)centerYWithinMargins {
+    return [self addConstraintWithLayoutAttribute:NSLayoutAttributeCenterYWithinMargins];
+}
+
+#endif
+
+
+#pragma mark - composite Attributes
+
+- (MASConstraint *)edges {
+    return [self addConstraintWithAttributes:MASAttributeTop | MASAttributeLeft | MASAttributeRight | MASAttributeBottom];
+}
+
+- (MASConstraint *)size {
+    return [self addConstraintWithAttributes:MASAttributeWidth | MASAttributeHeight];
+}
+
+- (MASConstraint *)center {
+    return [self addConstraintWithAttributes:MASAttributeCenterX | MASAttributeCenterY];
+}
+
+#pragma mark - grouping
+
+- (MASConstraint *(^)(dispatch_block_t group))group {
+    return ^id(dispatch_block_t group) {
+        NSInteger previousCount = self.constraints.count;
+        group();
+
+        NSArray *children = [self.constraints subarrayWithRange:NSMakeRange(previousCount, self.constraints.count - previousCount)];
+        MASCompositeConstraint *constraint = [[MASCompositeConstraint alloc] initWithChildren:children];
+        constraint.delegate = self;
+        return constraint;
+    };
+}
+
+@end

+ 22 - 0
PDFViewer/Masonry/MASLayoutConstraint.h

@@ -0,0 +1,22 @@
+//
+//  MASLayoutConstraint.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 3/08/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import "MASUtilities.h"
+
+/**
+ *	When you are debugging or printing the constraints attached to a view this subclass
+ *  makes it easier to identify which constraints have been created via Masonry
+ */
+@interface MASLayoutConstraint : NSLayoutConstraint
+
+/**
+ *	a key to associate with this constraint
+ */
+@property (nonatomic, strong) id mas_key;
+
+@end

+ 13 - 0
PDFViewer/Masonry/MASLayoutConstraint.m

@@ -0,0 +1,13 @@
+//
+//  MASLayoutConstraint.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 3/08/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import "MASLayoutConstraint.h"
+
+@implementation MASLayoutConstraint
+
+@end

+ 136 - 0
PDFViewer/Masonry/MASUtilities.h

@@ -0,0 +1,136 @@
+//
+//  MASUtilities.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 19/08/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+    #import <UIKit/UIKit.h>
+    #define MAS_VIEW UIView
+    #define MAS_VIEW_CONTROLLER UIViewController
+    #define MASEdgeInsets UIEdgeInsets
+
+    typedef UILayoutPriority MASLayoutPriority;
+    static const MASLayoutPriority MASLayoutPriorityRequired = UILayoutPriorityRequired;
+    static const MASLayoutPriority MASLayoutPriorityDefaultHigh = UILayoutPriorityDefaultHigh;
+    static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 500;
+    static const MASLayoutPriority MASLayoutPriorityDefaultLow = UILayoutPriorityDefaultLow;
+    static const MASLayoutPriority MASLayoutPriorityFittingSizeLevel = UILayoutPriorityFittingSizeLevel;
+
+#elif TARGET_OS_MAC
+
+    #import <AppKit/AppKit.h>
+    #define MAS_VIEW NSView
+    #define MASEdgeInsets NSEdgeInsets
+
+    typedef NSLayoutPriority MASLayoutPriority;
+    static const MASLayoutPriority MASLayoutPriorityRequired = NSLayoutPriorityRequired;
+    static const MASLayoutPriority MASLayoutPriorityDefaultHigh = NSLayoutPriorityDefaultHigh;
+    static const MASLayoutPriority MASLayoutPriorityDragThatCanResizeWindow = NSLayoutPriorityDragThatCanResizeWindow;
+    static const MASLayoutPriority MASLayoutPriorityDefaultMedium = 501;
+    static const MASLayoutPriority MASLayoutPriorityWindowSizeStayPut = NSLayoutPriorityWindowSizeStayPut;
+    static const MASLayoutPriority MASLayoutPriorityDragThatCannotResizeWindow = NSLayoutPriorityDragThatCannotResizeWindow;
+    static const MASLayoutPriority MASLayoutPriorityDefaultLow = NSLayoutPriorityDefaultLow;
+    static const MASLayoutPriority MASLayoutPriorityFittingSizeCompression = NSLayoutPriorityFittingSizeCompression;
+
+#endif
+
+/**
+ *	Allows you to attach keys to objects matching the variable names passed.
+ *
+ *  view1.mas_key = @"view1", view2.mas_key = @"view2";
+ *
+ *  is equivalent to:
+ *
+ *  MASAttachKeys(view1, view2);
+ */
+#define MASAttachKeys(...)                                                        \
+    {                                                                             \
+        NSDictionary *keyPairs = NSDictionaryOfVariableBindings(__VA_ARGS__);     \
+        for (id key in keyPairs.allKeys) {                                        \
+            id obj = keyPairs[key];                                               \
+            NSAssert([obj respondsToSelector:@selector(setMas_key:)],             \
+                     @"Cannot attach mas_key to %@", obj);                        \
+            [obj setMas_key:key];                                                 \
+        }                                                                         \
+    }
+
+/**
+ *  Used to create object hashes
+ *  Based on http://www.mikeash.com/pyblog/friday-qa-2010-06-18-implementing-equality-and-hashing.html
+ */
+#define MAS_NSUINT_BIT (CHAR_BIT * sizeof(NSUInteger))
+#define MAS_NSUINTROTATE(val, howmuch) ((((NSUInteger)val) << howmuch) | (((NSUInteger)val) >> (MAS_NSUINT_BIT - howmuch)))
+
+/**
+ *  Given a scalar or struct value, wraps it in NSValue
+ *  Based on EXPObjectify: https://github.com/specta/expecta
+ */
+static inline id _MASBoxValue(const char *type, ...) {
+    va_list v;
+    va_start(v, type);
+    id obj = nil;
+    if (strcmp(type, @encode(id)) == 0) {
+        id actual = va_arg(v, id);
+        obj = actual;
+    } else if (strcmp(type, @encode(CGPoint)) == 0) {
+        CGPoint actual = (CGPoint)va_arg(v, CGPoint);
+        obj = [NSValue value:&actual withObjCType:type];
+    } else if (strcmp(type, @encode(CGSize)) == 0) {
+        CGSize actual = (CGSize)va_arg(v, CGSize);
+        obj = [NSValue value:&actual withObjCType:type];
+    } else if (strcmp(type, @encode(MASEdgeInsets)) == 0) {
+        MASEdgeInsets actual = (MASEdgeInsets)va_arg(v, MASEdgeInsets);
+        obj = [NSValue value:&actual withObjCType:type];
+    } else if (strcmp(type, @encode(double)) == 0) {
+        double actual = (double)va_arg(v, double);
+        obj = [NSNumber numberWithDouble:actual];
+    } else if (strcmp(type, @encode(float)) == 0) {
+        float actual = (float)va_arg(v, double);
+        obj = [NSNumber numberWithFloat:actual];
+    } else if (strcmp(type, @encode(int)) == 0) {
+        int actual = (int)va_arg(v, int);
+        obj = [NSNumber numberWithInt:actual];
+    } else if (strcmp(type, @encode(long)) == 0) {
+        long actual = (long)va_arg(v, long);
+        obj = [NSNumber numberWithLong:actual];
+    } else if (strcmp(type, @encode(long long)) == 0) {
+        long long actual = (long long)va_arg(v, long long);
+        obj = [NSNumber numberWithLongLong:actual];
+    } else if (strcmp(type, @encode(short)) == 0) {
+        short actual = (short)va_arg(v, int);
+        obj = [NSNumber numberWithShort:actual];
+    } else if (strcmp(type, @encode(char)) == 0) {
+        char actual = (char)va_arg(v, int);
+        obj = [NSNumber numberWithChar:actual];
+    } else if (strcmp(type, @encode(bool)) == 0) {
+        bool actual = (bool)va_arg(v, int);
+        obj = [NSNumber numberWithBool:actual];
+    } else if (strcmp(type, @encode(unsigned char)) == 0) {
+        unsigned char actual = (unsigned char)va_arg(v, unsigned int);
+        obj = [NSNumber numberWithUnsignedChar:actual];
+    } else if (strcmp(type, @encode(unsigned int)) == 0) {
+        unsigned int actual = (unsigned int)va_arg(v, unsigned int);
+        obj = [NSNumber numberWithUnsignedInt:actual];
+    } else if (strcmp(type, @encode(unsigned long)) == 0) {
+        unsigned long actual = (unsigned long)va_arg(v, unsigned long);
+        obj = [NSNumber numberWithUnsignedLong:actual];
+    } else if (strcmp(type, @encode(unsigned long long)) == 0) {
+        unsigned long long actual = (unsigned long long)va_arg(v, unsigned long long);
+        obj = [NSNumber numberWithUnsignedLongLong:actual];
+    } else if (strcmp(type, @encode(unsigned short)) == 0) {
+        unsigned short actual = (unsigned short)va_arg(v, unsigned int);
+        obj = [NSNumber numberWithUnsignedShort:actual];
+    }
+    va_end(v);
+    return obj;
+}
+
+#define MASBoxValue(value) _MASBoxValue(@encode(__typeof__((value))), (value))

+ 49 - 0
PDFViewer/Masonry/MASViewAttribute.h

@@ -0,0 +1,49 @@
+//
+//  MASViewAttribute.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 21/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASUtilities.h"
+
+/**
+ *  An immutable tuple which stores the view and the related NSLayoutAttribute.
+ *  Describes part of either the left or right hand side of a constraint equation
+ */
+@interface MASViewAttribute : NSObject
+
+/**
+ *  The view which the reciever relates to. Can be nil if item is not a view.
+ */
+@property (nonatomic, weak, readonly) MAS_VIEW *view;
+
+/**
+ *  The item which the reciever relates to.
+ */
+@property (nonatomic, weak, readonly) id item;
+
+/**
+ *  The attribute which the reciever relates to
+ */
+@property (nonatomic, assign, readonly) NSLayoutAttribute layoutAttribute;
+
+/**
+ *  Convenience initializer.
+ */
+- (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute;
+
+/**
+ *  The designated initializer.
+ */
+- (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute;
+
+/**
+ *	Determine whether the layoutAttribute is a size attribute
+ *
+ *	@return	YES if layoutAttribute is equal to NSLayoutAttributeWidth or NSLayoutAttributeHeight
+ */
+- (BOOL)isSizeAttribute;
+
+@end

+ 46 - 0
PDFViewer/Masonry/MASViewAttribute.m

@@ -0,0 +1,46 @@
+//
+//  MASViewAttribute.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 21/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASViewAttribute.h"
+
+@implementation MASViewAttribute
+
+- (id)initWithView:(MAS_VIEW *)view layoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    self = [self initWithView:view item:view layoutAttribute:layoutAttribute];
+    return self;
+}
+
+- (id)initWithView:(MAS_VIEW *)view item:(id)item layoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    self = [super init];
+    if (!self) return nil;
+    
+    _view = view;
+    _item = item;
+    _layoutAttribute = layoutAttribute;
+    
+    return self;
+}
+
+- (BOOL)isSizeAttribute {
+    return self.layoutAttribute == NSLayoutAttributeWidth
+        || self.layoutAttribute == NSLayoutAttributeHeight;
+}
+
+- (BOOL)isEqual:(MASViewAttribute *)viewAttribute {
+    if ([viewAttribute isKindOfClass:self.class]) {
+        return self.view == viewAttribute.view
+            && self.layoutAttribute == viewAttribute.layoutAttribute;
+    }
+    return [super isEqual:viewAttribute];
+}
+
+- (NSUInteger)hash {
+    return MAS_NSUINTROTATE([self.view hash], MAS_NSUINT_BIT / 2) ^ self.layoutAttribute;
+}
+
+@end

+ 48 - 0
PDFViewer/Masonry/MASViewConstraint.h

@@ -0,0 +1,48 @@
+//
+//  MASViewConstraint.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASViewAttribute.h"
+#import "MASConstraint.h"
+#import "MASLayoutConstraint.h"
+#import "MASUtilities.h"
+
+/**
+ *  A single constraint.
+ *  Contains the attributes neccessary for creating a NSLayoutConstraint and adding it to the appropriate view
+ */
+@interface MASViewConstraint : MASConstraint <NSCopying>
+
+/**
+ *	First item/view and first attribute of the NSLayoutConstraint
+ */
+@property (nonatomic, strong, readonly) MASViewAttribute *firstViewAttribute;
+
+/**
+ *	Second item/view and second attribute of the NSLayoutConstraint
+ */
+@property (nonatomic, strong, readonly) MASViewAttribute *secondViewAttribute;
+
+/**
+ *	initialises the MASViewConstraint with the first part of the equation
+ *
+ *	@param	firstViewAttribute	view.mas_left, view.mas_width etc.
+ *
+ *	@return	a new view constraint
+ */
+- (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute;
+
+/**
+ *  Returns all MASViewConstraints installed with this view as a first item.
+ *
+ *  @param  view  A view to retrieve constraints for.
+ *
+ *  @return An array of MASViewConstraints.
+ */
++ (NSArray *)installedConstraintsForView:(MAS_VIEW *)view;
+
+@end

+ 406 - 0
PDFViewer/Masonry/MASViewConstraint.m

@@ -0,0 +1,406 @@
+//
+//  MASViewConstraint.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASViewConstraint.h"
+#import "MASConstraint+Private.h"
+#import "MASCompositeConstraint.h"
+#import "MASLayoutConstraint.h"
+#import "View+MASAdditions.h"
+#import <objc/runtime.h>
+
+@interface MAS_VIEW (MASConstraints)
+
+@property (nonatomic, readonly) NSMutableSet *mas_installedConstraints;
+
+@end
+
+@implementation MAS_VIEW (MASConstraints)
+
+static char kInstalledConstraintsKey;
+
+- (NSMutableSet *)mas_installedConstraints {
+    NSMutableSet *constraints = objc_getAssociatedObject(self, &kInstalledConstraintsKey);
+    if (!constraints) {
+        constraints = [NSMutableSet set];
+        objc_setAssociatedObject(self, &kInstalledConstraintsKey, constraints, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+    }
+    return constraints;
+}
+
+@end
+
+
+@interface MASViewConstraint ()
+
+@property (nonatomic, strong, readwrite) MASViewAttribute *secondViewAttribute;
+@property (nonatomic, weak) MAS_VIEW *installedView;
+@property (nonatomic, weak) MASLayoutConstraint *layoutConstraint;
+@property (nonatomic, assign) NSLayoutRelation layoutRelation;
+@property (nonatomic, assign) MASLayoutPriority layoutPriority;
+@property (nonatomic, assign) CGFloat layoutMultiplier;
+@property (nonatomic, assign) CGFloat layoutConstant;
+@property (nonatomic, assign) BOOL hasLayoutRelation;
+@property (nonatomic, strong) id mas_key;
+@property (nonatomic, assign) BOOL useAnimator;
+
+@end
+
+@implementation MASViewConstraint
+
+- (id)initWithFirstViewAttribute:(MASViewAttribute *)firstViewAttribute {
+    self = [super init];
+    if (!self) return nil;
+    
+    _firstViewAttribute = firstViewAttribute;
+    self.layoutPriority = MASLayoutPriorityRequired;
+    self.layoutMultiplier = 1;
+    
+    return self;
+}
+
+#pragma mark - NSCoping
+
+- (id)copyWithZone:(NSZone __unused *)zone {
+    MASViewConstraint *constraint = [[MASViewConstraint alloc] initWithFirstViewAttribute:self.firstViewAttribute];
+    constraint.layoutConstant = self.layoutConstant;
+    constraint.layoutRelation = self.layoutRelation;
+    constraint.layoutPriority = self.layoutPriority;
+    constraint.layoutMultiplier = self.layoutMultiplier;
+    constraint.delegate = self.delegate;
+    return constraint;
+}
+
+#pragma mark - Public
+
++ (NSArray *)installedConstraintsForView:(MAS_VIEW *)view {
+    return [view.mas_installedConstraints allObjects];
+}
+
+#pragma mark - Private
+
+- (void)setLayoutConstant:(CGFloat)layoutConstant {
+    _layoutConstant = layoutConstant;
+
+#if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
+    if (self.useAnimator) {
+        [self.layoutConstraint.animator setConstant:layoutConstant];
+    } else {
+        self.layoutConstraint.constant = layoutConstant;
+    }
+#else
+    self.layoutConstraint.constant = layoutConstant;
+#endif
+}
+
+- (void)setLayoutRelation:(NSLayoutRelation)layoutRelation {
+    _layoutRelation = layoutRelation;
+    self.hasLayoutRelation = YES;
+}
+
+- (BOOL)supportsActiveProperty {
+    return [self.layoutConstraint respondsToSelector:@selector(isActive)];
+}
+
+- (BOOL)isActive {
+    BOOL active = YES;
+    if ([self supportsActiveProperty]) {
+        active = [self.layoutConstraint isActive];
+    }
+
+    return active;
+}
+
+- (BOOL)hasBeenInstalled {
+    return (self.layoutConstraint != nil) && [self isActive];
+}
+
+- (void)setSecondViewAttribute:(id)secondViewAttribute {
+    if ([secondViewAttribute isKindOfClass:NSValue.class]) {
+        [self setLayoutConstantWithValue:secondViewAttribute];
+    } else if ([secondViewAttribute isKindOfClass:MAS_VIEW.class]) {
+        _secondViewAttribute = [[MASViewAttribute alloc] initWithView:secondViewAttribute layoutAttribute:self.firstViewAttribute.layoutAttribute];
+    } else if ([secondViewAttribute isKindOfClass:MASViewAttribute.class]) {
+        MASViewAttribute *attr = secondViewAttribute;
+        if (attr.layoutAttribute == NSLayoutAttributeNotAnAttribute) {
+            _secondViewAttribute = [[MASViewAttribute alloc] initWithView:attr.view item:attr.item layoutAttribute:self.firstViewAttribute.layoutAttribute];;
+        } else {
+            _secondViewAttribute = secondViewAttribute;
+        }
+    } else {
+        NSAssert(NO, @"attempting to add unsupported attribute: %@", secondViewAttribute);
+    }
+}
+
+#pragma mark - NSLayoutConstraint multiplier proxies
+
+- (MASConstraint * (^)(CGFloat))multipliedBy {
+    return ^id(CGFloat multiplier) {
+        NSAssert(!self.hasBeenInstalled,
+                 @"Cannot modify constraint multiplier after it has been installed");
+        
+        self.layoutMultiplier = multiplier;
+        return self;
+    };
+}
+
+
+- (MASConstraint * (^)(CGFloat))dividedBy {
+    return ^id(CGFloat divider) {
+        NSAssert(!self.hasBeenInstalled,
+                 @"Cannot modify constraint multiplier after it has been installed");
+
+        self.layoutMultiplier = 1.0/divider;
+        return self;
+    };
+}
+
+#pragma mark - MASLayoutPriority proxy
+
+- (MASConstraint * (^)(MASLayoutPriority))priority {
+    return ^id(MASLayoutPriority priority) {
+        NSAssert(!self.hasBeenInstalled,
+                 @"Cannot modify constraint priority after it has been installed");
+        
+        self.layoutPriority = priority;
+        return self;
+    };
+}
+
+#pragma mark - NSLayoutRelation proxy
+
+- (MASConstraint * (^)(id, NSLayoutRelation))equalToWithRelation {
+    return ^id(id attribute, NSLayoutRelation relation) {
+        if ([attribute isKindOfClass:NSArray.class]) {
+            NSAssert(!self.hasLayoutRelation, @"Redefinition of constraint relation");
+            NSMutableArray *children = NSMutableArray.new;
+            for (id attr in attribute) {
+                MASViewConstraint *viewConstraint = [self copy];
+                viewConstraint.layoutRelation = relation;
+                viewConstraint.secondViewAttribute = attr;
+                [children addObject:viewConstraint];
+            }
+            MASCompositeConstraint *compositeConstraint = [[MASCompositeConstraint alloc] initWithChildren:children];
+            compositeConstraint.delegate = self.delegate;
+            [self.delegate constraint:self shouldBeReplacedWithConstraint:compositeConstraint];
+            return compositeConstraint;
+        } else {
+            NSAssert(!self.hasLayoutRelation || self.layoutRelation == relation && [attribute isKindOfClass:NSValue.class], @"Redefinition of constraint relation");
+            self.layoutRelation = relation;
+            self.secondViewAttribute = attribute;
+            return self;
+        }
+    };
+}
+
+#pragma mark - Semantic properties
+
+- (MASConstraint *)with {
+    return self;
+}
+
+- (MASConstraint *)and {
+    return self;
+}
+
+#pragma mark - attribute chaining
+
+- (MASConstraint *)addConstraintWithLayoutAttribute:(NSLayoutAttribute)layoutAttribute {
+    NSAssert(!self.hasLayoutRelation, @"Attributes should be chained before defining the constraint relation");
+
+    return [self.delegate constraint:self addConstraintWithLayoutAttribute:layoutAttribute];
+}
+
+#pragma mark - Animator proxy
+
+#if TARGET_OS_MAC && !(TARGET_OS_IPHONE || TARGET_OS_TV)
+
+- (MASConstraint *)animator {
+    self.useAnimator = YES;
+    return self;
+}
+
+#endif
+
+#pragma mark - debug helpers
+
+- (MASConstraint * (^)(id))key {
+    return ^id(id key) {
+        self.mas_key = key;
+        return self;
+    };
+}
+
+#pragma mark - NSLayoutConstraint constant setters
+
+- (void)setInsets:(MASEdgeInsets)insets {
+    NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
+    switch (layoutAttribute) {
+        case NSLayoutAttributeLeft:
+        case NSLayoutAttributeLeading:
+            self.layoutConstant = insets.left;
+            break;
+        case NSLayoutAttributeTop:
+            self.layoutConstant = insets.top;
+            break;
+        case NSLayoutAttributeBottom:
+            self.layoutConstant = -insets.bottom;
+            break;
+        case NSLayoutAttributeRight:
+        case NSLayoutAttributeTrailing:
+            self.layoutConstant = -insets.right;
+            break;
+        default:
+            break;
+    }
+}
+
+- (void)setInset:(CGFloat)inset {
+    [self setInsets:(MASEdgeInsets){.top = inset, .left = inset, .bottom = inset, .right = inset}];
+}
+
+- (void)setOffset:(CGFloat)offset {
+    self.layoutConstant = offset;
+}
+
+- (void)setSizeOffset:(CGSize)sizeOffset {
+    NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
+    switch (layoutAttribute) {
+        case NSLayoutAttributeWidth:
+            self.layoutConstant = sizeOffset.width;
+            break;
+        case NSLayoutAttributeHeight:
+            self.layoutConstant = sizeOffset.height;
+            break;
+        default:
+            break;
+    }
+}
+
+- (void)setCenterOffset:(CGPoint)centerOffset {
+    NSLayoutAttribute layoutAttribute = self.firstViewAttribute.layoutAttribute;
+    switch (layoutAttribute) {
+        case NSLayoutAttributeCenterX:
+            self.layoutConstant = centerOffset.x;
+            break;
+        case NSLayoutAttributeCenterY:
+            self.layoutConstant = centerOffset.y;
+            break;
+        default:
+            break;
+    }
+}
+
+#pragma mark - MASConstraint
+
+- (void)activate {
+    [self install];
+}
+
+- (void)deactivate {
+    [self uninstall];
+}
+
+- (void)install {
+    if (self.hasBeenInstalled) {
+        return;
+    }
+    
+    if ([self supportsActiveProperty] && self.layoutConstraint) {
+        self.layoutConstraint.active = YES;
+        [self.firstViewAttribute.view.mas_installedConstraints addObject:self];
+        return;
+    }
+    
+    MAS_VIEW *firstLayoutItem = self.firstViewAttribute.item;
+    NSLayoutAttribute firstLayoutAttribute = self.firstViewAttribute.layoutAttribute;
+    MAS_VIEW *secondLayoutItem = self.secondViewAttribute.item;
+    NSLayoutAttribute secondLayoutAttribute = self.secondViewAttribute.layoutAttribute;
+
+    // alignment attributes must have a secondViewAttribute
+    // therefore we assume that is refering to superview
+    // eg make.left.equalTo(@10)
+    if (!self.firstViewAttribute.isSizeAttribute && !self.secondViewAttribute) {
+        secondLayoutItem = self.firstViewAttribute.view.superview;
+        secondLayoutAttribute = firstLayoutAttribute;
+    }
+    
+    MASLayoutConstraint *layoutConstraint
+        = [MASLayoutConstraint constraintWithItem:firstLayoutItem
+                                        attribute:firstLayoutAttribute
+                                        relatedBy:self.layoutRelation
+                                           toItem:secondLayoutItem
+                                        attribute:secondLayoutAttribute
+                                       multiplier:self.layoutMultiplier
+                                         constant:self.layoutConstant];
+    
+    layoutConstraint.priority = self.layoutPriority;
+    layoutConstraint.mas_key = self.mas_key;
+    
+    if (self.secondViewAttribute.view) {
+        MAS_VIEW *closestCommonSuperview = [self.firstViewAttribute.view mas_closestCommonSuperview:self.secondViewAttribute.view];
+        NSAssert(closestCommonSuperview,
+                 @"couldn't find a common superview for %@ and %@",
+                 self.firstViewAttribute.view, self.secondViewAttribute.view);
+        self.installedView = closestCommonSuperview;
+    } else if (self.firstViewAttribute.isSizeAttribute) {
+        self.installedView = self.firstViewAttribute.view;
+    } else {
+        self.installedView = self.firstViewAttribute.view.superview;
+    }
+
+
+    MASLayoutConstraint *existingConstraint = nil;
+    if (self.updateExisting) {
+        existingConstraint = [self layoutConstraintSimilarTo:layoutConstraint];
+    }
+    if (existingConstraint) {
+        // just update the constant
+        existingConstraint.constant = layoutConstraint.constant;
+        self.layoutConstraint = existingConstraint;
+    } else {
+        [self.installedView addConstraint:layoutConstraint];
+        self.layoutConstraint = layoutConstraint;
+        [firstLayoutItem.mas_installedConstraints addObject:self];
+    }
+}
+
+- (MASLayoutConstraint *)layoutConstraintSimilarTo:(MASLayoutConstraint *)layoutConstraint {
+    // check if any constraints are the same apart from the only mutable property constant
+
+    // go through constraints in reverse as we do not want to match auto-resizing or interface builder constraints
+    // and they are likely to be added first.
+    for (NSLayoutConstraint *existingConstraint in self.installedView.constraints.reverseObjectEnumerator) {
+        if (![existingConstraint isKindOfClass:MASLayoutConstraint.class]) continue;
+        if (existingConstraint.firstItem != layoutConstraint.firstItem) continue;
+        if (existingConstraint.secondItem != layoutConstraint.secondItem) continue;
+        if (existingConstraint.firstAttribute != layoutConstraint.firstAttribute) continue;
+        if (existingConstraint.secondAttribute != layoutConstraint.secondAttribute) continue;
+        if (existingConstraint.relation != layoutConstraint.relation) continue;
+        if (existingConstraint.multiplier != layoutConstraint.multiplier) continue;
+        if (existingConstraint.priority != layoutConstraint.priority) continue;
+
+        return (id)existingConstraint;
+    }
+    return nil;
+}
+
+- (void)uninstall {
+    if ([self supportsActiveProperty]) {
+        self.layoutConstraint.active = NO;
+        [self.firstViewAttribute.view.mas_installedConstraints removeObject:self];
+        return;
+    }
+    
+    [self.installedView removeConstraint:self.layoutConstraint];
+    self.layoutConstraint = nil;
+    self.installedView = nil;
+    
+    [self.firstViewAttribute.view.mas_installedConstraints removeObject:self];
+}
+
+@end

+ 29 - 0
PDFViewer/Masonry/Masonry.h

@@ -0,0 +1,29 @@
+//
+//  Masonry.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+//! Project version number for Masonry.
+FOUNDATION_EXPORT double MasonryVersionNumber;
+
+//! Project version string for Masonry.
+FOUNDATION_EXPORT const unsigned char MasonryVersionString[];
+
+#import "MASUtilities.h"
+#import "View+MASAdditions.h"
+#import "View+MASShorthandAdditions.h"
+#import "ViewController+MASAdditions.h"
+#import "NSArray+MASAdditions.h"
+#import "NSArray+MASShorthandAdditions.h"
+#import "MASConstraint.h"
+#import "MASCompositeConstraint.h"
+#import "MASViewAttribute.h"
+#import "MASViewConstraint.h"
+#import "MASConstraintMaker.h"
+#import "MASLayoutConstraint.h"
+#import "NSLayoutConstraint+MASDebugAdditions.h"

+ 72 - 0
PDFViewer/Masonry/NSArray+MASAdditions.h

@@ -0,0 +1,72 @@
+//
+//  NSArray+MASAdditions.h
+//
+//
+//  Created by Daniel Hammond on 11/26/13.
+//
+//
+
+#import "MASUtilities.h"
+#import "MASConstraintMaker.h"
+#import "MASViewAttribute.h"
+
+typedef NS_ENUM(NSUInteger, MASAxisType) {
+    MASAxisTypeHorizontal,
+    MASAxisTypeVertical
+};
+
+@interface NSArray (MASAdditions)
+
+/**
+ *  Creates a MASConstraintMaker with each view in the callee.
+ *  Any constraints defined are added to the view or the appropriate superview once the block has finished executing on each view
+ *
+ *  @param block scope within which you can build up the constraints which you wish to apply to each view.
+ *
+ *  @return Array of created MASConstraints
+ */
+- (NSArray *)mas_makeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
+
+/**
+ *  Creates a MASConstraintMaker with each view in the callee.
+ *  Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
+ *  If an existing constraint exists then it will be updated instead.
+ *
+ *  @param block scope within which you can build up the constraints which you wish to apply to each view.
+ *
+ *  @return Array of created/updated MASConstraints
+ */
+- (NSArray *)mas_updateConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
+
+/**
+ *  Creates a MASConstraintMaker with each view in the callee.
+ *  Any constraints defined are added to each view or the appropriate superview once the block has finished executing on each view.
+ *  All constraints previously installed for the views will be removed.
+ *
+ *  @param block scope within which you can build up the constraints which you wish to apply to each view.
+ *
+ *  @return Array of created/updated MASConstraints
+ */
+- (NSArray *)mas_remakeConstraints:(void (NS_NOESCAPE ^)(MASConstraintMaker *make))block;
+
+/**
+ *  distribute with fixed spacing
+ *
+ *  @param axisType     which axis to distribute items along
+ *  @param fixedSpacing the spacing between each item
+ *  @param leadSpacing  the spacing before the first item and the container
+ *  @param tailSpacing  the spacing after the last item and the container
+ */
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
+
+/**
+ *  distribute with fixed item size
+ *
+ *  @param axisType        which axis to distribute items along
+ *  @param fixedItemLength the fixed length of each item
+ *  @param leadSpacing     the spacing before the first item and the container
+ *  @param tailSpacing     the spacing after the last item and the container
+ */
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing;
+
+@end

+ 162 - 0
PDFViewer/Masonry/NSArray+MASAdditions.m

@@ -0,0 +1,162 @@
+//
+//  NSArray+MASAdditions.m
+//  
+//
+//  Created by Daniel Hammond on 11/26/13.
+//
+//
+
+#import "NSArray+MASAdditions.h"
+#import "View+MASAdditions.h"
+
+@implementation NSArray (MASAdditions)
+
+- (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block {
+    NSMutableArray *constraints = [NSMutableArray array];
+    for (MAS_VIEW *view in self) {
+        NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views");
+        [constraints addObjectsFromArray:[view mas_makeConstraints:block]];
+    }
+    return constraints;
+}
+
+- (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *make))block {
+    NSMutableArray *constraints = [NSMutableArray array];
+    for (MAS_VIEW *view in self) {
+        NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views");
+        [constraints addObjectsFromArray:[view mas_updateConstraints:block]];
+    }
+    return constraints;
+}
+
+- (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block {
+    NSMutableArray *constraints = [NSMutableArray array];
+    for (MAS_VIEW *view in self) {
+        NSAssert([view isKindOfClass:[MAS_VIEW class]], @"All objects in the array must be views");
+        [constraints addObjectsFromArray:[view mas_remakeConstraints:block]];
+    }
+    return constraints;
+}
+
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedSpacing:(CGFloat)fixedSpacing leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
+    if (self.count < 2) {
+        NSAssert(self.count>1,@"views to distribute need to bigger than one");
+        return;
+    }
+    
+    MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
+    if (axisType == MASAxisTypeHorizontal) {
+        MAS_VIEW *prev;
+        for (int i = 0; i < self.count; i++) {
+            MAS_VIEW *v = self[i];
+            [v mas_makeConstraints:^(MASConstraintMaker *make) {
+                if (prev) {
+                    make.width.equalTo(prev);
+                    make.left.equalTo(prev.mas_right).offset(fixedSpacing);
+                    if (i == self.count - 1) {//last one
+                        make.right.equalTo(tempSuperView).offset(-tailSpacing);
+                    }
+                }
+                else {//first one
+                    make.left.equalTo(tempSuperView).offset(leadSpacing);
+                }
+                
+            }];
+            prev = v;
+        }
+    }
+    else {
+        MAS_VIEW *prev;
+        for (int i = 0; i < self.count; i++) {
+            MAS_VIEW *v = self[i];
+            [v mas_makeConstraints:^(MASConstraintMaker *make) {
+                if (prev) {
+                    make.height.equalTo(prev);
+                    make.top.equalTo(prev.mas_bottom).offset(fixedSpacing);
+                    if (i == self.count - 1) {//last one
+                        make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
+                    }                    
+                }
+                else {//first one
+                    make.top.equalTo(tempSuperView).offset(leadSpacing);
+                }
+                
+            }];
+            prev = v;
+        }
+    }
+}
+
+- (void)mas_distributeViewsAlongAxis:(MASAxisType)axisType withFixedItemLength:(CGFloat)fixedItemLength leadSpacing:(CGFloat)leadSpacing tailSpacing:(CGFloat)tailSpacing {
+    if (self.count < 2) {
+        NSAssert(self.count>1,@"views to distribute need to bigger than one");
+        return;
+    }
+    
+    MAS_VIEW *tempSuperView = [self mas_commonSuperviewOfViews];
+    if (axisType == MASAxisTypeHorizontal) {
+        MAS_VIEW *prev;
+        for (int i = 0; i < self.count; i++) {
+            MAS_VIEW *v = self[i];
+            [v mas_makeConstraints:^(MASConstraintMaker *make) {
+                make.width.equalTo(@(fixedItemLength));
+                if (prev) {
+                    if (i == self.count - 1) {//last one
+                        make.right.equalTo(tempSuperView).offset(-tailSpacing);
+                    }
+                    else {
+                        CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
+                        make.right.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset);
+                    }
+                }
+                else {//first one
+                    make.left.equalTo(tempSuperView).offset(leadSpacing);
+                }
+            }];
+            prev = v;
+        }
+    }
+    else {
+        MAS_VIEW *prev;
+        for (int i = 0; i < self.count; i++) {
+            MAS_VIEW *v = self[i];
+            [v mas_makeConstraints:^(MASConstraintMaker *make) {
+                make.height.equalTo(@(fixedItemLength));
+                if (prev) {
+                    if (i == self.count - 1) {//last one
+                        make.bottom.equalTo(tempSuperView).offset(-tailSpacing);
+                    }
+                    else {
+                        CGFloat offset = (1-(i/((CGFloat)self.count-1)))*(fixedItemLength+leadSpacing)-i*tailSpacing/(((CGFloat)self.count-1));
+                        make.bottom.equalTo(tempSuperView).multipliedBy(i/((CGFloat)self.count-1)).with.offset(offset);
+                    }
+                }
+                else {//first one
+                    make.top.equalTo(tempSuperView).offset(leadSpacing);
+                }
+            }];
+            prev = v;
+        }
+    }
+}
+
+- (MAS_VIEW *)mas_commonSuperviewOfViews
+{
+    MAS_VIEW *commonSuperview = nil;
+    MAS_VIEW *previousView = nil;
+    for (id object in self) {
+        if ([object isKindOfClass:[MAS_VIEW class]]) {
+            MAS_VIEW *view = (MAS_VIEW *)object;
+            if (previousView) {
+                commonSuperview = [view mas_closestCommonSuperview:commonSuperview];
+            } else {
+                commonSuperview = view;
+            }
+            previousView = view;
+        }
+    }
+    NSAssert(commonSuperview, @"Can't constrain views that do not share a common superview. Make sure that all the views in this array have been added into the same view hierarchy.");
+    return commonSuperview;
+}
+
+@end

+ 41 - 0
PDFViewer/Masonry/NSArray+MASShorthandAdditions.h

@@ -0,0 +1,41 @@
+//
+//  NSArray+MASShorthandAdditions.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 22/07/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import "NSArray+MASAdditions.h"
+
+#ifdef MAS_SHORTHAND
+
+/**
+ *	Shorthand array additions without the 'mas_' prefixes,
+ *  only enabled if MAS_SHORTHAND is defined
+ */
+@interface NSArray (MASShorthandAdditions)
+
+- (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
+- (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
+- (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
+
+@end
+
+@implementation NSArray (MASShorthandAdditions)
+
+- (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block {
+    return [self mas_makeConstraints:block];
+}
+
+- (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block {
+    return [self mas_updateConstraints:block];
+}
+
+- (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block {
+    return [self mas_remakeConstraints:block];
+}
+
+@end
+
+#endif

+ 16 - 0
PDFViewer/Masonry/NSLayoutConstraint+MASDebugAdditions.h

@@ -0,0 +1,16 @@
+//
+//  NSLayoutConstraint+MASDebugAdditions.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 3/08/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import "MASUtilities.h"
+
+/**
+ *	makes debug and log output of NSLayoutConstraints more readable
+ */
+@interface NSLayoutConstraint (MASDebugAdditions)
+
+@end

+ 143 - 0
PDFViewer/Masonry/NSLayoutConstraint+MASDebugAdditions.m

@@ -0,0 +1,143 @@
+//
+//  NSLayoutConstraint+MASDebugAdditions.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 3/08/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import "NSLayoutConstraint+MASDebugAdditions.h"
+#import "MASConstraint.h"
+#import "MASLayoutConstraint.h"
+
+@implementation NSLayoutConstraint (MASDebugAdditions)
+
+#pragma mark - description maps
+
++ (NSDictionary *)layoutRelationDescriptionsByValue {
+    static dispatch_once_t once;
+    static NSDictionary *descriptionMap;
+    dispatch_once(&once, ^{
+        descriptionMap = @{
+            @(NSLayoutRelationEqual)                : @"==",
+            @(NSLayoutRelationGreaterThanOrEqual)   : @">=",
+            @(NSLayoutRelationLessThanOrEqual)      : @"<=",
+        };
+    });
+    return descriptionMap;
+}
+
++ (NSDictionary *)layoutAttributeDescriptionsByValue {
+    static dispatch_once_t once;
+    static NSDictionary *descriptionMap;
+    dispatch_once(&once, ^{
+        descriptionMap = @{
+            @(NSLayoutAttributeTop)      : @"top",
+            @(NSLayoutAttributeLeft)     : @"left",
+            @(NSLayoutAttributeBottom)   : @"bottom",
+            @(NSLayoutAttributeRight)    : @"right",
+            @(NSLayoutAttributeLeading)  : @"leading",
+            @(NSLayoutAttributeTrailing) : @"trailing",
+            @(NSLayoutAttributeWidth)    : @"width",
+            @(NSLayoutAttributeHeight)   : @"height",
+            @(NSLayoutAttributeCenterX)  : @"centerX",
+            @(NSLayoutAttributeCenterY)  : @"centerY",
+            @(NSLayoutAttributeBaseline) : @"baseline",
+            @(NSLayoutAttributeFirstBaseline) : @"firstBaseline",
+            @(NSLayoutAttributeLastBaseline) : @"lastBaseline",
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+            @(NSLayoutAttributeLeftMargin)           : @"leftMargin",
+            @(NSLayoutAttributeRightMargin)          : @"rightMargin",
+            @(NSLayoutAttributeTopMargin)            : @"topMargin",
+            @(NSLayoutAttributeBottomMargin)         : @"bottomMargin",
+            @(NSLayoutAttributeLeadingMargin)        : @"leadingMargin",
+            @(NSLayoutAttributeTrailingMargin)       : @"trailingMargin",
+            @(NSLayoutAttributeCenterXWithinMargins) : @"centerXWithinMargins",
+            @(NSLayoutAttributeCenterYWithinMargins) : @"centerYWithinMargins",
+#endif
+            
+        };
+    
+    });
+    return descriptionMap;
+}
+
+
++ (NSDictionary *)layoutPriorityDescriptionsByValue {
+    static dispatch_once_t once;
+    static NSDictionary *descriptionMap;
+    dispatch_once(&once, ^{
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+        descriptionMap = @{
+            @(MASLayoutPriorityDefaultHigh)      : @"high",
+            @(MASLayoutPriorityDefaultLow)       : @"low",
+            @(MASLayoutPriorityDefaultMedium)    : @"medium",
+            @(MASLayoutPriorityRequired)         : @"required",
+            @(MASLayoutPriorityFittingSizeLevel) : @"fitting size",
+        };
+#elif TARGET_OS_MAC
+        descriptionMap = @{
+            @(MASLayoutPriorityDefaultHigh)                 : @"high",
+            @(MASLayoutPriorityDragThatCanResizeWindow)     : @"drag can resize window",
+            @(MASLayoutPriorityDefaultMedium)               : @"medium",
+            @(MASLayoutPriorityWindowSizeStayPut)           : @"window size stay put",
+            @(MASLayoutPriorityDragThatCannotResizeWindow)  : @"drag cannot resize window",
+            @(MASLayoutPriorityDefaultLow)                  : @"low",
+            @(MASLayoutPriorityFittingSizeCompression)      : @"fitting size",
+            @(MASLayoutPriorityRequired)                    : @"required",
+        };
+#endif
+    });
+    return descriptionMap;
+}
+
+#pragma mark - description override
+
++ (NSString *)descriptionForObject:(id)obj {
+    if ([obj respondsToSelector:@selector(mas_key)] && [obj mas_key]) {
+        return [NSString stringWithFormat:@"%@:%@", [obj class], [obj mas_key]];
+    }
+    return [NSString stringWithFormat:@"%@:%p", [obj class], obj];
+}
+
+- (NSString *)description {
+    NSMutableString *description = [[NSMutableString alloc] initWithString:@"<"];
+
+    [description appendString:[self.class descriptionForObject:self]];
+
+    [description appendFormat:@" %@", [self.class descriptionForObject:self.firstItem]];
+    if (self.firstAttribute != NSLayoutAttributeNotAnAttribute) {
+        [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.firstAttribute)]];
+    }
+
+    [description appendFormat:@" %@", self.class.layoutRelationDescriptionsByValue[@(self.relation)]];
+
+    if (self.secondItem) {
+        [description appendFormat:@" %@", [self.class descriptionForObject:self.secondItem]];
+    }
+    if (self.secondAttribute != NSLayoutAttributeNotAnAttribute) {
+        [description appendFormat:@".%@", self.class.layoutAttributeDescriptionsByValue[@(self.secondAttribute)]];
+    }
+    
+    if (self.multiplier != 1) {
+        [description appendFormat:@" * %g", self.multiplier];
+    }
+    
+    if (self.secondAttribute == NSLayoutAttributeNotAnAttribute) {
+        [description appendFormat:@" %g", self.constant];
+    } else {
+        if (self.constant) {
+            [description appendFormat:@" %@ %g", (self.constant < 0 ? @"-" : @"+"), ABS(self.constant)];
+        }
+    }
+
+    if (self.priority != MASLayoutPriorityRequired) {
+        [description appendFormat:@" ^%@", self.class.layoutPriorityDescriptionsByValue[@(self.priority)] ?: [NSNumber numberWithDouble:self.priority]];
+    }
+
+    [description appendString:@">"];
+    return description;
+}
+
+@end

+ 109 - 0
PDFViewer/Masonry/View+MASAdditions.h

@@ -0,0 +1,109 @@
+//
+//  UIView+MASAdditions.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "MASUtilities.h"
+#import "MASConstraintMaker.h"
+#import "MASViewAttribute.h"
+
+/**
+ *	Provides constraint maker block
+ *  and convience methods for creating MASViewAttribute which are view + NSLayoutAttribute pairs
+ */
+@interface MAS_VIEW (MASAdditions)
+
+/**
+ *	following properties return a new MASViewAttribute with current view and appropriate NSLayoutAttribute
+ */
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_left;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_top;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_right;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottom;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_leading;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_trailing;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_width;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_height;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerX;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerY;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_baseline;
+@property (nonatomic, strong, readonly) MASViewAttribute *(^mas_attribute)(NSLayoutAttribute attr);
+
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_firstBaseline;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_lastBaseline;
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
+
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuide NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeading NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTrailing NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideLeft NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideRight NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideTop NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideBottom NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideWidth NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideHeight NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterX NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_safeAreaLayoutGuideCenterY NS_AVAILABLE_IOS(11.0);
+
+#endif
+
+/**
+ *	a key to associate with this view
+ */
+@property (nonatomic, strong) id mas_key;
+
+/**
+ *	Finds the closest common superview between this view and another view
+ *
+ *	@param	view	other view
+ *
+ *	@return	returns nil if common superview could not be found
+ */
+- (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view;
+
+/**
+ *  Creates a MASConstraintMaker with the callee view.
+ *  Any constraints defined are added to the view or the appropriate superview once the block has finished executing
+ *
+ *  @param block scope within which you can build up the constraints which you wish to apply to the view.
+ *
+ *  @return Array of created MASConstraints
+ */
+- (NSArray *)mas_makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block;
+
+/**
+ *  Creates a MASConstraintMaker with the callee view.
+ *  Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
+ *  If an existing constraint exists then it will be updated instead.
+ *
+ *  @param block scope within which you can build up the constraints which you wish to apply to the view.
+ *
+ *  @return Array of created/updated MASConstraints
+ */
+- (NSArray *)mas_updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block;
+
+/**
+ *  Creates a MASConstraintMaker with the callee view.
+ *  Any constraints defined are added to the view or the appropriate superview once the block has finished executing.
+ *  All constraints previously installed for the view will be removed.
+ *
+ *  @param block scope within which you can build up the constraints which you wish to apply to the view.
+ *
+ *  @return Array of created/updated MASConstraints
+ */
+- (NSArray *)mas_remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *make))block;
+
+@end

+ 206 - 0
PDFViewer/Masonry/View+MASAdditions.m

@@ -0,0 +1,206 @@
+//
+//  UIView+MASAdditions.m
+//  Masonry
+//
+//  Created by Jonas Budelmann on 20/07/13.
+//  Copyright (c) 2013 cloudling. All rights reserved.
+//
+
+#import "View+MASAdditions.h"
+#import <objc/runtime.h>
+
+@implementation MAS_VIEW (MASAdditions)
+
+- (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *))block {
+    self.translatesAutoresizingMaskIntoConstraints = NO;
+    MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
+    block(constraintMaker);
+    return [constraintMaker install];
+}
+
+- (NSArray *)mas_updateConstraints:(void(^)(MASConstraintMaker *))block {
+    self.translatesAutoresizingMaskIntoConstraints = NO;
+    MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
+    constraintMaker.updateExisting = YES;
+    block(constraintMaker);
+    return [constraintMaker install];
+}
+
+- (NSArray *)mas_remakeConstraints:(void(^)(MASConstraintMaker *make))block {
+    self.translatesAutoresizingMaskIntoConstraints = NO;
+    MASConstraintMaker *constraintMaker = [[MASConstraintMaker alloc] initWithView:self];
+    constraintMaker.removeExisting = YES;
+    block(constraintMaker);
+    return [constraintMaker install];
+}
+
+#pragma mark - NSLayoutAttribute properties
+
+- (MASViewAttribute *)mas_left {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeft];
+}
+
+- (MASViewAttribute *)mas_top {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTop];
+}
+
+- (MASViewAttribute *)mas_right {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRight];
+}
+
+- (MASViewAttribute *)mas_bottom {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottom];
+}
+
+- (MASViewAttribute *)mas_leading {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeading];
+}
+
+- (MASViewAttribute *)mas_trailing {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailing];
+}
+
+- (MASViewAttribute *)mas_width {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeWidth];
+}
+
+- (MASViewAttribute *)mas_height {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeHeight];
+}
+
+- (MASViewAttribute *)mas_centerX {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterX];
+}
+
+- (MASViewAttribute *)mas_centerY {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterY];
+}
+
+- (MASViewAttribute *)mas_baseline {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBaseline];
+}
+
+- (MASViewAttribute *(^)(NSLayoutAttribute))mas_attribute
+{
+    return ^(NSLayoutAttribute attr) {
+        return [[MASViewAttribute alloc] initWithView:self layoutAttribute:attr];
+    };
+}
+
+- (MASViewAttribute *)mas_firstBaseline {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeFirstBaseline];
+}
+- (MASViewAttribute *)mas_lastBaseline {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLastBaseline];
+}
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+- (MASViewAttribute *)mas_leftMargin {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeftMargin];
+}
+
+- (MASViewAttribute *)mas_rightMargin {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeRightMargin];
+}
+
+- (MASViewAttribute *)mas_topMargin {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTopMargin];
+}
+
+- (MASViewAttribute *)mas_bottomMargin {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeBottomMargin];
+}
+
+- (MASViewAttribute *)mas_leadingMargin {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeLeadingMargin];
+}
+
+- (MASViewAttribute *)mas_trailingMargin {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeTrailingMargin];
+}
+
+- (MASViewAttribute *)mas_centerXWithinMargins {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterXWithinMargins];
+}
+
+- (MASViewAttribute *)mas_centerYWithinMargins {
+    return [[MASViewAttribute alloc] initWithView:self layoutAttribute:NSLayoutAttributeCenterYWithinMargins];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuide {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeNotAnAttribute];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideLeading {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeading];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideTrailing {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTrailing];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideLeft {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeLeft];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideRight {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeRight];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideTop {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeTop];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideBottom {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideWidth {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeWidth];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideHeight {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeHeight];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideCenterX {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeCenterX];
+}
+
+- (MASViewAttribute *)mas_safeAreaLayoutGuideCenterY {
+    return [[MASViewAttribute alloc] initWithView:self item:self.safeAreaLayoutGuide layoutAttribute:NSLayoutAttributeCenterY];
+}
+
+#endif
+
+#pragma mark - associated properties
+
+- (id)mas_key {
+    return objc_getAssociatedObject(self, @selector(mas_key));
+}
+
+- (void)setMas_key:(id)key {
+    objc_setAssociatedObject(self, @selector(mas_key), key, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+}
+
+#pragma mark - heirachy
+
+- (instancetype)mas_closestCommonSuperview:(MAS_VIEW *)view {
+    MAS_VIEW *closestCommonSuperview = nil;
+
+    MAS_VIEW *secondViewSuperview = view;
+    while (!closestCommonSuperview && secondViewSuperview) {
+        MAS_VIEW *firstViewSuperview = self;
+        while (!closestCommonSuperview && firstViewSuperview) {
+            if (secondViewSuperview == firstViewSuperview) {
+                closestCommonSuperview = secondViewSuperview;
+            }
+            firstViewSuperview = firstViewSuperview.superview;
+        }
+        secondViewSuperview = secondViewSuperview.superview;
+    }
+    return closestCommonSuperview;
+}
+
+@end

+ 138 - 0
PDFViewer/Masonry/View+MASShorthandAdditions.h

@@ -0,0 +1,138 @@
+//
+//  UIView+MASShorthandAdditions.h
+//  Masonry
+//
+//  Created by Jonas Budelmann on 22/07/13.
+//  Copyright (c) 2013 Jonas Budelmann. All rights reserved.
+//
+
+#import "View+MASAdditions.h"
+
+#ifdef MAS_SHORTHAND
+
+/**
+ *	Shorthand view additions without the 'mas_' prefixes,
+ *  only enabled if MAS_SHORTHAND is defined
+ */
+@interface MAS_VIEW (MASShorthandAdditions)
+
+@property (nonatomic, strong, readonly) MASViewAttribute *left;
+@property (nonatomic, strong, readonly) MASViewAttribute *top;
+@property (nonatomic, strong, readonly) MASViewAttribute *right;
+@property (nonatomic, strong, readonly) MASViewAttribute *bottom;
+@property (nonatomic, strong, readonly) MASViewAttribute *leading;
+@property (nonatomic, strong, readonly) MASViewAttribute *trailing;
+@property (nonatomic, strong, readonly) MASViewAttribute *width;
+@property (nonatomic, strong, readonly) MASViewAttribute *height;
+@property (nonatomic, strong, readonly) MASViewAttribute *centerX;
+@property (nonatomic, strong, readonly) MASViewAttribute *centerY;
+@property (nonatomic, strong, readonly) MASViewAttribute *baseline;
+@property (nonatomic, strong, readonly) MASViewAttribute *(^attribute)(NSLayoutAttribute attr);
+
+@property (nonatomic, strong, readonly) MASViewAttribute *firstBaseline;
+@property (nonatomic, strong, readonly) MASViewAttribute *lastBaseline;
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+@property (nonatomic, strong, readonly) MASViewAttribute *leftMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *rightMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *topMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *bottomMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *leadingMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *trailingMargin;
+@property (nonatomic, strong, readonly) MASViewAttribute *centerXWithinMargins;
+@property (nonatomic, strong, readonly) MASViewAttribute *centerYWithinMargins;
+
+#endif
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeading NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTrailing NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideLeft NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideRight NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideTop NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideBottom NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideWidth NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideHeight NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideCenterX NS_AVAILABLE_IOS(11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *safeAreaLayoutGuideCenterY NS_AVAILABLE_IOS(11.0);
+
+#endif
+
+- (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *make))block;
+- (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *make))block;
+- (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *make))block;
+
+@end
+
+#define MAS_ATTR_FORWARD(attr)  \
+- (MASViewAttribute *)attr {    \
+    return [self mas_##attr];   \
+}
+
+#define MAS_ATTR_FORWARD_AVAILABLE(attr, available)  \
+- (MASViewAttribute *)attr available {    \
+    return [self mas_##attr];   \
+}
+
+@implementation MAS_VIEW (MASShorthandAdditions)
+
+MAS_ATTR_FORWARD(top);
+MAS_ATTR_FORWARD(left);
+MAS_ATTR_FORWARD(bottom);
+MAS_ATTR_FORWARD(right);
+MAS_ATTR_FORWARD(leading);
+MAS_ATTR_FORWARD(trailing);
+MAS_ATTR_FORWARD(width);
+MAS_ATTR_FORWARD(height);
+MAS_ATTR_FORWARD(centerX);
+MAS_ATTR_FORWARD(centerY);
+MAS_ATTR_FORWARD(baseline);
+
+MAS_ATTR_FORWARD(firstBaseline);
+MAS_ATTR_FORWARD(lastBaseline);
+
+#if TARGET_OS_IPHONE || TARGET_OS_TV
+
+MAS_ATTR_FORWARD(leftMargin);
+MAS_ATTR_FORWARD(rightMargin);
+MAS_ATTR_FORWARD(topMargin);
+MAS_ATTR_FORWARD(bottomMargin);
+MAS_ATTR_FORWARD(leadingMargin);
+MAS_ATTR_FORWARD(trailingMargin);
+MAS_ATTR_FORWARD(centerXWithinMargins);
+MAS_ATTR_FORWARD(centerYWithinMargins);
+
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeading, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTrailing, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeft, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideRight, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTop, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideBottom, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideWidth, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideHeight, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterX, NS_AVAILABLE_IOS(11.0));
+MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterY, NS_AVAILABLE_IOS(11.0));
+
+#endif
+
+- (MASViewAttribute *(^)(NSLayoutAttribute))attribute {
+    return [self mas_attribute];
+}
+
+- (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block {
+    return [self mas_makeConstraints:block];
+}
+
+- (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block {
+    return [self mas_updateConstraints:block];
+}
+
+- (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block {
+    return [self mas_remakeConstraints:block];
+}
+
+@end
+
+#endif

+ 29 - 0
PDFViewer/Masonry/ViewController+MASAdditions.h

@@ -0,0 +1,29 @@
+//
+//  UIViewController+MASAdditions.h
+//  Masonry
+//
+//  Created by Craig Siemens on 2015-06-23.
+//
+//
+
+#import "MASUtilities.h"
+#import "MASConstraintMaker.h"
+#import "MASViewAttribute.h"
+
+#ifdef MAS_VIEW_CONTROLLER
+
+@interface MAS_VIEW_CONTROLLER (MASAdditions)
+
+/**
+ *	following properties return a new MASViewAttribute with appropriate UILayoutGuide and NSLayoutAttribute
+ */
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuide NS_DEPRECATED_IOS(8.0, 11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuide NS_DEPRECATED_IOS(8.0, 11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideTop NS_DEPRECATED_IOS(8.0, 11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_topLayoutGuideBottom NS_DEPRECATED_IOS(8.0, 11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideTop NS_DEPRECATED_IOS(8.0, 11.0);
+@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomLayoutGuideBottom NS_DEPRECATED_IOS(8.0, 11.0);
+
+@end
+
+#endif

+ 42 - 0
PDFViewer/Masonry/ViewController+MASAdditions.m

@@ -0,0 +1,42 @@
+//
+//  UIViewController+MASAdditions.m
+//  Masonry
+//
+//  Created by Craig Siemens on 2015-06-23.
+//
+//
+
+#import "ViewController+MASAdditions.h"
+
+#ifdef MAS_VIEW_CONTROLLER
+
+@implementation MAS_VIEW_CONTROLLER (MASAdditions)
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+
+- (MASViewAttribute *)mas_topLayoutGuide {
+    return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
+}
+- (MASViewAttribute *)mas_topLayoutGuideTop {
+    return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeTop];
+}
+- (MASViewAttribute *)mas_topLayoutGuideBottom {
+    return [[MASViewAttribute alloc] initWithView:self.view item:self.topLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
+}
+
+- (MASViewAttribute *)mas_bottomLayoutGuide {
+    return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
+}
+- (MASViewAttribute *)mas_bottomLayoutGuideTop {
+    return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeTop];
+}
+- (MASViewAttribute *)mas_bottomLayoutGuideBottom {
+    return [[MASViewAttribute alloc] initWithView:self.view item:self.bottomLayoutGuide layoutAttribute:NSLayoutAttributeBottom];
+}
+
+#pragma clang diagnostic pop
+
+@end
+
+#endif

+ 24 - 0
PDFViewer/Model/CPDFModelData.h

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

+ 12 - 0
PDFViewer/Model/CPDFModelData.m

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

+ 0 - 16
PDFViewer/View/BatesAddView.h

@@ -1,16 +0,0 @@
-//
-//  BatesAddView.h
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/18.
-//
-
-#import <UIKit/UIKit.h>
-
-NS_ASSUME_NONNULL_BEGIN
-
-@interface BatesAddView : UIView
-
-@end
-
-NS_ASSUME_NONNULL_END

+ 0 - 20
PDFViewer/View/BatesAddView.m

@@ -1,20 +0,0 @@
-//
-//  BatesAddView.m
-//  PDFViewer
-//
-//  Created by kdanmobile_2 on 2022/11/18.
-//
-
-#import "BatesAddView.h"
-
-@implementation BatesAddView
-
-/*
-// Only override drawRect: if you perform custom drawing.
-// An empty implementation adversely affects performance during animation.
-- (void)drawRect:(CGRect)rect {
-    // Drawing code
-}
-*/
-
-@end

+ 31 - 0
PDFViewer/View/CPDFBatesAddView.h

@@ -0,0 +1,31 @@
+//
+//  BatesAddView.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/18.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFBatesAddView : 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;
+@property (nonatomic,strong) UILabel *pageNumberLabel;
+@property (nonatomic,strong) UITextField *pageNumberText;
+@property (nonatomic,strong) UILabel *fontNameLabel;
+@property (nonatomic,strong) UITextField *fontNameText;
+@property (nonatomic,strong) UILabel *pageIndexLabel;
+@property (nonatomic,strong) UILabel *pageIndexNumberLabel;
+@property (nonatomic,strong) UIStepper *pageIndexNumberStepper;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 102 - 0
PDFViewer/View/CPDFBatesAddView.m

@@ -0,0 +1,102 @@
+//
+//  BatesAddView.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/18.
+//
+
+#import "CPDFBatesAddView.h"
+
+@implementation CPDFBatesAddView
+
+- (instancetype)initWithFrame:(CGRect)frame {
+    self = [super initWithFrame:frame];
+    CGFloat height = self.bounds.size.height / 15 - 35;
+    CGFloat width  = self.bounds.size.width / 4 - 10;
+    CGFloat offsetx = 3.5;
+    if (self) {
+        //Page number location
+        _localLabel = [[UILabel alloc] initWithFrame:CGRectMake(offsetx, offsetx, width * 2, height)];
+        [_localLabel setText:@"Page number position"];
+        _localLabel.font = [UIFont boldSystemFontOfSize:12];
+        NSArray *arraySegmmentL = [NSArray arrayWithObjects:@"Header",@"Footer", nil];
+        _localSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentL];
+        _localSegment.frame = CGRectMake(3.5, height + 2 * offsetx, self.bounds.size.width - 8 * offsetx, height * 2);
+        [self addSubview:_localLabel];
+        [self addSubview:_localSegment];
+        //alignment
+        _alignmentLabel = [[UILabel alloc] initWithFrame:CGRectMake(3.5, 3 * height + 3 * offsetx, width, height)];
+        [_alignmentLabel setText:@"alignment"];
+        _alignmentLabel.font = [UIFont boldSystemFontOfSize:12];
+        NSArray *arraySegmmentA = [NSArray arrayWithObjects:@"Left",@"Center",@"Right", nil];
+        _aligbmentSegment = [[UISegmentedControl alloc] initWithItems:arraySegmmentA];
+        _aligbmentSegment.frame = CGRectMake(3.5, 4 * height + 4 * offsetx, self.bounds.size.width - 8 * offsetx, height * 2);
+        [self addSubview:_alignmentLabel];
+        [self addSubview:_aligbmentSegment];
+        //font color
+        _colorLabel = [[UILabel alloc] initWithFrame:CGRectMake(3.5, 6 * height + 5 * offsetx, width, height)];
+        [_colorLabel setText:@"Font Color"];
+        _colorLabel.font = [UIFont boldSystemFontOfSize:12];
+        _colerImage = [[UIImageView alloc] initWithFrame:CGRectMake(3.5,7 * height + 6 * offsetx , self.bounds.size.width, 2*height)];
+        _colerImage.image = [UIImage imageNamed:@"text_color_bar"];
+        _colorSlider = [[UISlider alloc] initWithFrame:CGRectMake(3.5,9 * height + 7 * offsetx , self.bounds.size.width - 8 * offsetx, 2 * height)];
+        _colorSlider.minimumValue = 0;
+        _colorSlider.maximumValue = 90;
+        _colorSlider.value = 5;
+        [self addSubview:_colorLabel];
+        [self addSubview:_colorSlider];
+        [self addSubview:_colerImage];
+        //page number
+        _pageNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(3.5, 11 * height + 8 * offsetx, width + offsetx, height * 2)];
+        [_pageNumberLabel setText:@"Page Text"];
+        _pageNumberLabel.font = [UIFont boldSystemFontOfSize:14];
+        _pageNumberText = [[UITextField alloc] initWithFrame:CGRectMake(2 * offsetx + width, 11 * height + 8 * offsetx, width - offsetx, height * 2)];
+        _pageNumberText.borderStyle = UITextBorderStyleRoundedRect;
+        [self addSubview:_pageNumberLabel];
+        [self addSubview:_pageNumberText];
+        //font size
+        _fontNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(3 * offsetx + width * 2, 11 * height + 8 * offsetx, width, height * 2)];
+        [_fontNameLabel setText:@"Font Name"];
+        _fontNameLabel.font = [UIFont boldSystemFontOfSize:14];
+        _fontNameText = [[UITextField alloc] initWithFrame:CGRectMake(2 * offsetx + 3 * width, 11 * height + 8 * offsetx, width, height * 2)];
+        _fontNameText.borderStyle = UITextBorderStyleRoundedRect;
+        [self addSubview:_fontNameLabel];
+        [self addSubview:_fontNameText];
+        //font star
+        _pageIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(offsetx, 13 * height + 9 * offsetx, width, height * 2)];
+        [_pageIndexLabel setText:@"Page Star"];
+        _pageIndexLabel.font = [UIFont boldSystemFontOfSize:14];
+        _pageIndexNumberLabel = [[UILabel alloc] initWithFrame:CGRectMake(offsetx + width, 13 * height + 10 * offsetx, width, height * 2)];
+        _pageIndexNumberLabel.backgroundColor = [UIColor whiteColor];
+        _pageIndexNumberLabel.textColor = [UIColor blueColor];
+        _pageIndexNumberLabel.textAlignment = NSTextAlignmentCenter;
+        _pageIndexNumberStepper = [[UIStepper alloc] initWithFrame:CGRectMake(offsetx + width * 2, 13 * height + 11 * offsetx, width, height * 2)];
+        // The step value is updated in real time as the user interacts
+        _pageIndexNumberStepper.continuous = YES; // default = YES
+        // The user continues to press and hold, automatically increasing or decreasing
+        _pageIndexNumberStepper.autorepeat = YES; // default = YES
+        // If set to YES, the value loops between min <-> max
+        _pageIndexNumberStepper.wraps = NO; // default = NO
+        _pageIndexNumberStepper.minimumValue = 0;   // default 0
+        _pageIndexNumberStepper.maximumValue = 100; // default 100
+        _pageIndexNumberStepper.stepValue    = 1;   // default 1
+        _pageIndexNumberStepper.value = 1;
+        //setting Target-Action
+        [_pageIndexNumberStepper addTarget:self
+                    action:@selector(stepperValueChanged:)
+          forControlEvents:UIControlEventValueChanged];
+        [self addSubview:_pageIndexLabel];
+        [self addSubview:_pageIndexNumberLabel];
+        [self addSubview:_pageIndexNumberStepper];
+        
+        self.backgroundColor = [UIColor whiteColor];
+    }
+    return  self;
+}
+
+- (void)stepperValueChanged:(UIStepper *)pageIndexNumberStepper {
+    NSString *value = [NSString stringWithFormat:@"%f",pageIndexNumberStepper.value];
+    self.pageIndexNumberLabel.text = value;
+}
+
+@end

+ 31 - 0
PDFViewer/View/CPDFDropDownView.h

@@ -0,0 +1,31 @@
+//
+//  DropDownView.h
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/21.
+//
+
+#import <UIKit/UIKit.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+@interface CPDFDropDownView : UIView <UITableViewDelegate,UITableViewDataSource>
+
+@property (nonatomic,strong) UITextField *textField;
+@property (nonatomic,strong) NSArray *list;
+@property (nonatomic,strong) UITableView *listView;
+@property (nonatomic,strong) UIColor *lineColor;
+@property (nonatomic,retain) UIColor *listBgcolor;
+@property (nonatomic,assign) UITextBorderStyle borderStyle;
+@property (nonatomic,assign) BOOL showList;
+@property (nonatomic,assign) CGRect oldFrame;
+@property (nonatomic,assign) CGRect newFrame;
+@property (nonatomic,assign) CGFloat lineWidth;
+
+-(void)drawView;
+-(void)setShowList:(BOOL)b;
+- (id)initWithFrame:(CGRect)frame WithString:(NSArray *)str;
+
+@end
+
+NS_ASSUME_NONNULL_END

+ 99 - 0
PDFViewer/View/CPDFDropDownView.m

@@ -0,0 +1,99 @@
+//
+//  DropDownView.m
+//  PDFViewer
+//
+//  Created by kdanmobile_2 on 2022/11/21.
+//
+
+#import "CPDFDropDownView.h"
+
+@implementation CPDFDropDownView
+
+- (id)initWithFrame:(CGRect)frame WithString:(NSArray *)str{
+    if (self = [super initWithFrame:frame]) {
+        _list = str;
+        _borderStyle = UITextBorderStyleRoundedRect;
+        _showList = NO;
+        _oldFrame = frame;
+        _newFrame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height*3);
+        _lineColor = [UIColor lightGrayColor];
+        _listBgcolor = [UIColor whiteColor];
+        _lineWidth = 1;
+        self.backgroundColor=[UIColor clearColor];
+
+        [self drawView];
+    }
+    return self;
+}
+
+- (void)dropdown {
+    [_textField resignFirstResponder];
+    if (_showList) {
+        return;
+    } else {
+        [self.superview bringSubviewToFront:self];
+        [self setShowList:YES];
+    }
+    
+}
+
+- (void)drawView {
+    //Textfield
+    _textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, _oldFrame.size.width, _oldFrame.size.height)];
+    _textField.backgroundColor = [UIColor clearColor];
+    _textField.opaque = YES;
+    _textField.textColor = [UIColor blackColor];
+    _textField.font = [UIFont fontWithName:@"Arial" size:12.0];
+    _textField.borderStyle = _borderStyle;
+    //_textField.textAlignment = UITextAlignmentLeft;
+    [self addSubview:_textField];
+    [_textField addTarget:self action:@selector(dropdown)forControlEvents:UIControlEventAllTouchEvents];
+    //dropdown list
+    _listView=[[UITableView alloc]initWithFrame:
+     CGRectMake(_lineWidth,_oldFrame.size.height+_lineWidth,
+    _oldFrame.size.width-_lineWidth*2,
+    _oldFrame.size.height*2-_lineWidth*2)];
+    _listView.dataSource = self;
+    _listView.delegate = self;
+    _listView.backgroundColor = _listBgcolor;
+    _listView.separatorColor = _lineColor;
+    _listView.hidden = !_showList;
+    [self addSubview:_listView];
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
+    return  _list.count;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
+    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"listwid"];
+    if (cell == nil) {
+        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"listwid"];
+    }
+    cell.textLabel.text = [_list objectAtIndex:indexPath.row];
+    cell.textLabel.font = _textField.font;
+    cell.selectionStyle = UITableViewCellSelectionStyleGray;
+    return  cell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return _oldFrame.size.height;
+}
+
+//When selecting a row in the drop-down list, set the value in the text box to hide the drop-down list
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    _textField.text = (NSString *)[_list objectAtIndex:indexPath.row];
+    [self setShowList:NO];
+}
+
+- (void)setShowList:(BOOL)b {
+    _showList = b;
+    if (_showList) {
+        self.frame = _newFrame;
+    } else {
+        self.frame = _oldFrame;
+    }
+    _listView.hidden = !b;
+}
+
+@end