Ver Fonte

PDFViewer(ios) - ui工程搭建

dengkang há 2 anos atrás
pai
commit
d87a3e1174

+ 16 - 0
PDFViewer.xcodeproj/project.pbxproj

@@ -19,6 +19,9 @@
 		EC6297B8292239A700D339EE /* CPDFModel.m in Sources */ = {isa = PBXBuildFile; fileRef = EC6297B7292239A700D339EE /* CPDFModel.m */; };
 		EC6297BD292239C200D339EE /* CPDFListController.m in Sources */ = {isa = PBXBuildFile; fileRef = EC6297BC292239C200D339EE /* CPDFListController.m */; };
 		ECC8831D2923352B00F6392E /* CPDFViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECC8831C2923352B00F6392E /* CPDFViewController.m */; };
+		ECE3196F2923888800DB9D2F /* CPDFWatermarkController.m in Sources */ = {isa = PBXBuildFile; fileRef = ECE3196E2923888800DB9D2F /* CPDFWatermarkController.m */; };
+		ECE319722923895C00DB9D2F /* CPDFWatermarkView.m in Sources */ = {isa = PBXBuildFile; fileRef = ECE319712923895C00DB9D2F /* CPDFWatermarkView.m */; };
+		ECE319742924849C00DB9D2F /* pdfImage@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = ECE319732924849C00DB9D2F /* pdfImage@2x.png */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXCopyFilesBuildPhase section */
@@ -55,6 +58,11 @@
 		EC6297BC292239C200D339EE /* CPDFListController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFListController.m; sourceTree = "<group>"; };
 		ECC8831B2923352B00F6392E /* CPDFViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFViewController.h; sourceTree = "<group>"; };
 		ECC8831C2923352B00F6392E /* CPDFViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFViewController.m; sourceTree = "<group>"; };
+		ECE3196D2923888800DB9D2F /* CPDFWatermarkController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFWatermarkController.h; sourceTree = "<group>"; };
+		ECE3196E2923888800DB9D2F /* CPDFWatermarkController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFWatermarkController.m; sourceTree = "<group>"; };
+		ECE319702923895C00DB9D2F /* CPDFWatermarkView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CPDFWatermarkView.h; sourceTree = "<group>"; };
+		ECE319712923895C00DB9D2F /* CPDFWatermarkView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CPDFWatermarkView.m; sourceTree = "<group>"; };
+		ECE319732924849C00DB9D2F /* pdfImage@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pdfImage@2x.png"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -98,6 +106,7 @@
 				EC62979029220F8300D339EE /* SceneDelegate.m */,
 				EC62979229220F8300D339EE /* ViewController.h */,
 				EC62979329220F8300D339EE /* ViewController.m */,
+				ECE319732924849C00DB9D2F /* pdfImage@2x.png */,
 				EC62979529220F8300D339EE /* Main.storyboard */,
 				EC62979829220F8400D339EE /* Assets.xcassets */,
 				EC62979A29220F8400D339EE /* LaunchScreen.storyboard */,
@@ -119,6 +128,8 @@
 		EC6297AE29222D4400D339EE /* View */ = {
 			isa = PBXGroup;
 			children = (
+				ECE319702923895C00DB9D2F /* CPDFWatermarkView.h */,
+				ECE319712923895C00DB9D2F /* CPDFWatermarkView.m */,
 			);
 			path = View;
 			sourceTree = "<group>";
@@ -130,6 +141,8 @@
 				EC6297BC292239C200D339EE /* CPDFListController.m */,
 				ECC8831B2923352B00F6392E /* CPDFViewController.h */,
 				ECC8831C2923352B00F6392E /* CPDFViewController.m */,
+				ECE3196D2923888800DB9D2F /* CPDFWatermarkController.h */,
+				ECE3196E2923888800DB9D2F /* CPDFWatermarkController.m */,
 			);
 			path = Controller;
 			sourceTree = "<group>";
@@ -192,6 +205,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				EC62979C29220F8400D339EE /* LaunchScreen.storyboard in Resources */,
+				ECE319742924849C00DB9D2F /* pdfImage@2x.png in Resources */,
 				EC62979929220F8400D339EE /* Assets.xcassets in Resources */,
 				EC62979729220F8300D339EE /* Main.storyboard in Resources */,
 			);
@@ -207,9 +221,11 @@
 				ECC8831D2923352B00F6392E /* CPDFViewController.m in Sources */,
 				EC62979429220F8300D339EE /* ViewController.m in Sources */,
 				EC6297B8292239A700D339EE /* CPDFModel.m in Sources */,
+				ECE3196F2923888800DB9D2F /* CPDFWatermarkController.m in Sources */,
 				EC62978E29220F8300D339EE /* AppDelegate.m in Sources */,
 				EC62979F29220F8400D339EE /* main.m in Sources */,
 				EC6297BD292239C200D339EE /* CPDFListController.m in Sources */,
+				ECE319722923895C00DB9D2F /* CPDFWatermarkView.m in Sources */,
 				EC62979129220F8300D339EE /* SceneDelegate.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

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


+ 14 - 5
PDFViewer/Base.lproj/Main.storyboard

@@ -1,24 +1,33 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+    <device id="retina6_1" orientation="portrait" appearance="light"/>
     <dependencies>
-        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17703"/>
         <capability name="Safe area layout guides" minToolsVersion="9.0"/>
+        <capability name="System colors in document resources" minToolsVersion="11.0"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
         <!--View Controller-->
         <scene sceneID="tne-QT-ifu">
             <objects>
-                <viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
+                <viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
                     <view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
-                        <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+                        <rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
                         <viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
+                        <color key="backgroundColor" systemColor="systemBackgroundColor"/>
                     </view>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
             </objects>
+            <point key="canvasLocation" x="-100.00000000000001" y="-297.32142857142856"/>
         </scene>
     </scenes>
+    <resources>
+        <systemColor name="systemBackgroundColor">
+            <color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
+        </systemColor>
+    </resources>
 </document>

+ 2 - 0
PDFViewer/Controller/CPDFListController.m

@@ -114,6 +114,8 @@
     } else {
         
         CPDFViewController *pdfViewcontroller = [[CPDFViewController alloc] initWithPath:[self.dataArray[indexPath.row] filePath]];
+//        UIPageControl *pageControl = [[UIPageControl alloc] init];
+//        pdfViewcontroller.navigationItem.rightBarButtonItem ;
         [self.navigationController pushViewController:pdfViewcontroller animated:YES];
         
     }

+ 2 - 0
PDFViewer/Controller/CPDFViewController.m

@@ -7,6 +7,7 @@
 
 
 #import <ComPDFKit/ComPDFKit.h>
+#import <ComPDFKit/CPDFWatermark.h>
 #import "CPDFViewController.h"
 
 @interface CPDFViewController ()
@@ -31,6 +32,7 @@
     pdfView.document = document;
     pdfView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
     [self.view addSubview:pdfView];
+    
 }
 
 @end

+ 16 - 0
PDFViewer/Controller/CPDFWatermarkController.h

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

+ 31 - 0
PDFViewer/Controller/CPDFWatermarkController.m

@@ -0,0 +1,31 @@
+//
+//  CPDFWatermarkController.m
+//  PDFViewer
+//
+//  Created by kdan on 2022/11/15.
+//
+
+#import "CPDFWatermarkController.h"
+
+@interface CPDFWatermarkController ()
+
+@end
+
+@implementation CPDFWatermarkController
+
+- (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

+ 18 - 0
PDFViewer/View/CPDFWatermarkView.h

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

+ 20 - 0
PDFViewer/View/CPDFWatermarkView.m

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

BIN
PDFViewer/pdfImage@2x.png