Skip to content

Commit e6fe77d

Browse files
committed
Add warning about unsupported smart insert
1 parent 6050463 commit e6fe77d

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Example/Example/Base.lproj/Main.storyboard

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@
2020
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
2121
<subviews>
2222
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="_ (___) ____ ____" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vrS-aj-jzx" customClass="FormattedTextField" customModule="Example" customModuleProvider="target">
23+
<rect key="frame" x="16" y="40" width="343" height="30"/>
2324
<nil key="textColor"/>
2425
<fontDescription key="fontDescription" type="system" pointSize="20"/>
25-
<textInputTraits key="textInputTraits"/>
26+
<textInputTraits key="textInputTraits" smartInsertDeleteType="no"/>
2627
<userDefinedRuntimeAttributes>
2728
<userDefinedRuntimeAttribute type="string" keyPath="textMask" value="+× ××× ××× ××××××××"/>
2829
</userDefinedRuntimeAttributes>

FormattedTextField/FormattedTextField.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,13 @@ open class FormattedTextField: UITextField {
4747
} else if let placeholder = super.placeholder {
4848
placeholderLabel.text = placeholder
4949
}
50-
// iOS 11: placeholderRect(forBounds:) returns empty rect when placeholder is empty
51-
super.placeholder = " "
50+
if #available(iOS 11, *) {
51+
// iOS 11: placeholderRect(forBounds:) returns empty rect when placeholder is empty
52+
super.placeholder = " "
53+
if smartInsertDeleteType != .no {
54+
print("[FormattedTextField] warning: smartInsertDeleteType unsupports");
55+
}
56+
}
5257

5358
addSubview(placeholderLabel)
5459
}

0 commit comments

Comments
 (0)