Skip to content

Commit

Permalink
预设键盘类型和关闭自动校正
Browse files Browse the repository at this point in the history
  • Loading branch information
pcjbird committed Mar 31, 2018
1 parent 3830c1f commit e518f98
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 18 deletions.
2 changes: 1 addition & 1 deletion QuickMobileTextField.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QuickMobileTextField"
s.version = "1.0.2"
s.version = "1.0.3"
s.summary = "A Chinese mainland area mobile phone number input textfield. 中国大陆地区手机号码输入文本框。"
s.description = <<-DESC
A Chinese mainland area mobile phone number input textfield. 快速集成一个中国大陆地区手机号码输入文本框。
Expand Down
2 changes: 1 addition & 1 deletion QuickMobileTextField/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0.2</string>
<string>1.0.3</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
3 changes: 3 additions & 0 deletions QuickMobileTextField/QuickMobileTextField.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
// 框架名称:QuickMobileTextField
// 框架功能:A Chinese mainland area mobile phone number input textfield. 中国大陆地区手机号码输入文本框。
// 修改记录:
// pcjbird 2018-03-31 Version:1.0.3 Build:201803310001
// 1.预设键盘类型和关闭自动校正
//
// pcjbird 2018-03-30 Version:1.0.2 Build:201803300003
// 1.支持设置placeholder颜色
// 2.支持设置文字在输入框内的padding
Expand Down
4 changes: 4 additions & 0 deletions QuickMobileTextField/QuickMobileTextField.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ @implementation QuickMobileTextField
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
self.autocorrectionType = UITextAutocorrectionTypeNo;
self.keyboardType = UIKeyboardTypeDecimalPad;
[self addTarget:self action:@selector(reformatAsPhoneNumber:) forControlEvents:UIControlEventEditingChanged];
self.delegate = self;
}
Expand All @@ -30,6 +32,8 @@ - (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
self.autocorrectionType = UITextAutocorrectionTypeNo;
self.keyboardType = UIKeyboardTypeDecimalPad;
[self addTarget:self action:@selector(reformatAsPhoneNumber:) forControlEvents:UIControlEventEditingChanged];
self.delegate = self;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
89BC9ADE206E3EEA002DF76B /* Frameworks */,
89BC9ADF206E3EEA002DF76B /* Resources */,
B074E836E9BDC2C9B656BB38 /* [CP] Embed Pods Frameworks */,
4BA9E2970547C5B48C1B06AD /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -164,21 +163,6 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
4BA9E2970547C5B48C1B06AD /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "[CP] Copy Pods Resources";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-QuickMobileTextFieldDemo/Pods-QuickMobileTextFieldDemo-resources.sh\"\n";
showEnvVarsInLog = 0;
};
B074E836E9BDC2C9B656BB38 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,27 @@
</subviews>
<color key="backgroundColor" white="0.66666666669999997" alpha="0.1854368398" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" placeholder="请输入手机号码" textAlignment="natural" minimumFontSize="17" clearButtonMode="whileEditing" translatesAutoresizingMaskIntoConstraints="NO" id="PCh-Rn-bu2" customClass="QuickMobileTextField">
<rect key="frame" x="9" y="326" width="357" height="58"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" white="0.66666666666666663" alpha="0.18014233732876711" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="tintColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<nil key="textColor"/>
<fontDescription key="fontDescription" type="system" pointSize="21"/>
<textInputTraits key="textInputTraits"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="color" keyPath="placeholderColor">
<color key="value" red="0.96470588239999999" green="0.098039215690000001" blue="0.074509803920000006" alpha="1" colorSpace="calibratedRGB"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</textField>
</subviews>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
<connections>
<outlet property="mobileTextField" destination="eFb-Kx-dER" id="Uxl-um-hnI"/>
<outlet property="nextMobileTextField" destination="PCh-Rn-bu2" id="6vZ-iP-ZJw"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
@interface ViewController ()

@property (weak, nonatomic) IBOutlet QuickMobileTextField *mobileTextField;
@property (weak, nonatomic) IBOutlet QuickMobileTextField *nextMobileTextField;
@end

@implementation ViewController
Expand All @@ -20,6 +21,7 @@ - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.mobileTextField.mobile = @"1709";
self.nextMobileTextField.textInsets = UIEdgeInsetsMake(4, 15, 4, 15);
}


Expand Down

0 comments on commit e518f98

Please sign in to comment.