ソースを参照

【综合】PDF页面大小控制物件,输入框输入控制

niehaoyu 8 ヶ月 前
コミット
e1f4b34686

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/CustomStamp/Views/CustomStampTopToolbar.xib

@@ -79,7 +79,7 @@
                                 <textField focusRingType="none" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="ZIq-LE-awg">
                                     <rect key="frame" x="0.0" y="3" width="69" height="16"/>
                                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" focusRingType="none" alignment="center" title="100%" drawsBackground="YES" id="D7u-7E-JS8">
-                                        <numberFormatter key="formatter" formatterBehavior="10_0" positiveFormat="0%" negativeFormat="-0%" hasThousandSeparators="NO" thousandSeparator="," id="cDO-KT-LWy">
+                                        <numberFormatter key="formatter" formatterBehavior="10_0" positiveFormat="0%" negativeFormat="-0%" hasThousandSeparators="NO" thousandSeparator="," id="cDO-KT-LWy" customClass="KMCSTextFormatter" customModule="LynxPDF_Editor" customModuleProvider="target">
                                             <attributedString key="attributedStringForZero">
                                                 <fragment content="0%"/>
                                             </attributedString>

+ 28 - 0
PDF Office/PDF Master/Class/PDFTools/Tools/TextField/KMBaseTextFormatter.swift

@@ -47,3 +47,31 @@ class KMBaseTextFormatter: NumberFormatter {
         return nil
     }
 }
+
+class KMCSTextFormatter: NumberFormatter {
+     
+    override func isPartialStringValid(_ partialStringPtr: AutoreleasingUnsafeMutablePointer<NSString>, proposedSelectedRange proposedSelRangePtr: NSRangePointer?, originalString origString: String, originalSelectedRange origSelRange: NSRange, errorDescription error: AutoreleasingUnsafeMutablePointer<NSString?>?) -> Bool {
+       
+        var partialString = partialStringPtr.pointee
+        if partialString.debugDescription.isEmpty {
+            return true
+        }
+        
+            var regex: NSString = "^[0123456789.%]*$"
+           
+            let predicate = NSPredicate.init(format: "SELF MATCHES %@", regex)
+            if !predicate.evaluate(with: partialString) {
+                return false
+            }
+            
+        let newRange: NSRange = proposedSelRangePtr!.pointee
+        if (NSMaxRange(origSelRange) > NSMaxRange(newRange)) {
+            return true
+        }
+        return true
+    }
+    
+    override func attributedString(for obj: Any, withDefaultAttributes attrs: [NSAttributedString.Key : Any]? = nil) -> NSAttributedString? {
+        return nil
+    }
+}

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarController.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarController" customModule="PDF_Reader_Pro" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarController" customModule="LynxPDF_Editor" customModuleProvider="target">
             <connections>
                 <outlet property="bottomOffset" destination="13q-tk-M06" id="wDV-8G-vPv"/>
                 <outlet property="childToolBarBox" destination="aNc-zO-23T" id="f2v-x5-6Se"/>
@@ -25,7 +25,7 @@
             <rect key="frame" x="0.0" y="0.0" width="652" height="127"/>
             <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
             <subviews>
-                <customView translatesAutoresizingMaskIntoConstraints="NO" id="tGD-NS-sob" customClass="KMSearchFindView" customModule="PDF_Reader_Pro" customModuleProvider="target">
+                <customView translatesAutoresizingMaskIntoConstraints="NO" id="tGD-NS-sob" customClass="KMSearchFindView" customModule="LynxPDF_Editor" customModuleProvider="target">
                     <rect key="frame" x="152" y="0.0" width="500" height="25"/>
                     <constraints>
                         <constraint firstAttribute="height" constant="25" id="4Rt-cP-Bov"/>

+ 2 - 2
PDF Office/PDF Master/Class/PDFWindowController/Toolbar/KMToolbarViewController.xib

@@ -6,7 +6,7 @@
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarViewController" customModule="PDFTech_Editor" customModuleProvider="target">
+        <customObject id="-2" userLabel="File's Owner" customClass="KMToolbarViewController" customModule="LynxPDF_Editor" customModuleProvider="target">
             <connections>
                 <outlet property="view" destination="Hz6-mo-xeY" id="0bl-1N-x8E"/>
                 <outlet property="zoomButton" destination="sfH-r9-sge" id="eXr-4T-CdS"/>
@@ -31,7 +31,7 @@
                         <constraint firstAttribute="width" constant="40" id="oRp-g3-9io"/>
                     </constraints>
                     <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" focusRingType="none" alignment="left" title="100%" drawsBackground="YES" id="IdP-GL-aQz">
-                        <numberFormatter key="formatter" formatterBehavior="10_0" positiveFormat="0%" negativeFormat="-0%" hasThousandSeparators="NO" thousandSeparator="," id="xzG-LJ-Kwc">
+                        <numberFormatter key="formatter" formatterBehavior="10_0" positiveFormat="0%" negativeFormat="-0%" hasThousandSeparators="NO" thousandSeparator="," id="xzG-LJ-Kwc" customClass="KMCSTextFormatter" customModule="LynxPDF_Editor" customModuleProvider="target">
                             <attributedString key="attributedStringForZero">
                                 <fragment content="0%"/>
                             </attributedString>