Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf8036ccf0 | |||
| 1dfd86ba3b | |||
| cfaf5ea7ce | |||
| 0ff12c3e50 | |||
| 5dfe1f7108 | |||
| 7209def338 | |||
| 27f5b20eac | |||
| 4a01c4bf1b | |||
| bfcd10ed1d | |||
| 542b238cce | |||
| 37062db8aa | |||
| 1e873f189c | |||
| 536a243b78 | |||
| d968e5be6b | |||
| bfae0906bd | |||
| 7a6cd5efbb | |||
| 7c1d6bc4ae | |||
| 134ea16381 |
+1
-1
@@ -9,7 +9,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = 'DTTextField'
|
||||
s.version = '0.2.3'
|
||||
s.version = '0.4.0'
|
||||
s.summary = 'DTTextField is UITextField library.'
|
||||
|
||||
s.description = <<-DESC
|
||||
|
||||
@@ -24,18 +24,67 @@ public class DTTextField: UITextField {
|
||||
case defaults
|
||||
}
|
||||
|
||||
public enum DTBorderStyle{
|
||||
case none
|
||||
case rounded
|
||||
case sqare
|
||||
case top
|
||||
case bottom
|
||||
case left
|
||||
case right
|
||||
}
|
||||
|
||||
fileprivate var lblFloatPlaceholder:UILabel = UILabel()
|
||||
fileprivate var lblError:UILabel = UILabel()
|
||||
|
||||
fileprivate let paddingX:CGFloat = 5.0
|
||||
|
||||
fileprivate let paddingHeight:CGFloat = 10.0
|
||||
|
||||
fileprivate var borderLayer:CALayer = CALayer()
|
||||
public var dtLayer:CALayer = CALayer()
|
||||
public var floatPlaceholderColor:UIColor = UIColor.black
|
||||
public var floatPlaceholderActiveColor:UIColor = UIColor.black
|
||||
public var floatingLabelShowAnimationDuration = 0.3
|
||||
public var floatingDisplayStatus:FloatingDisplayStatus = .defaults
|
||||
public var borderWidth:CGFloat = 0.5{
|
||||
didSet{
|
||||
let borderStyle = dtborderStyle;
|
||||
dtborderStyle = borderStyle
|
||||
}
|
||||
}
|
||||
|
||||
public var dtborderStyle:DTBorderStyle = .rounded{
|
||||
didSet{
|
||||
borderLayer.removeFromSuperlayer()
|
||||
switch dtborderStyle {
|
||||
case .none:
|
||||
dtLayer.cornerRadius = 0.0
|
||||
dtLayer.borderWidth = 0.0
|
||||
case .rounded:
|
||||
dtLayer.cornerRadius = 4.5
|
||||
dtLayer.borderWidth = borderWidth
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
case .sqare:
|
||||
dtLayer.cornerRadius = 0.0
|
||||
dtLayer.borderWidth = borderWidth
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
case .bottom,.left,.right,.top:
|
||||
dtLayer.cornerRadius = 0.0
|
||||
dtLayer.borderWidth = 0.0
|
||||
borderLayer.backgroundColor = borderColor.cgColor
|
||||
if dtborderStyle == .bottom {
|
||||
borderLayer.frame = CGRect(x: 0, y: dtLayer.bounds.size.height - borderWidth, width: dtLayer.bounds.size.width, height: borderWidth)
|
||||
}else if dtborderStyle == .left{
|
||||
borderLayer.frame = CGRect(x: 0, y: 0, width: borderWidth, height: dtLayer.bounds.size.height)
|
||||
}else if dtborderStyle == .right{
|
||||
borderLayer.frame = CGRect(x: dtLayer.bounds.size.width - borderWidth, y: 0, width: borderWidth, height: dtLayer.bounds.size.height)
|
||||
}else{
|
||||
borderLayer.frame = CGRect(x: 0, y: 0, width: dtLayer.bounds.size.width, height: borderWidth)
|
||||
}
|
||||
dtLayer.addSublayer(borderLayer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var errorMessage:String = ""{
|
||||
didSet{ lblError.text = errorMessage }
|
||||
@@ -45,11 +94,17 @@ public class DTTextField: UITextField {
|
||||
public var hideErrorWhenEditing:Bool = true
|
||||
|
||||
public var errorFont = UIFont.systemFont(ofSize: 10.0){
|
||||
didSet{ invalidateIntrinsicContentSize() }
|
||||
didSet{
|
||||
lblError.font = errorFont
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
}
|
||||
|
||||
public var floatPlaceholderFont = UIFont.systemFont(ofSize: 10.0){
|
||||
didSet{ invalidateIntrinsicContentSize() }
|
||||
didSet{
|
||||
lblFloatPlaceholder.font = floatPlaceholderFont
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
}
|
||||
|
||||
public var paddingYFloatLabel:CGFloat = 3.0{
|
||||
@@ -61,25 +116,39 @@ public class DTTextField: UITextField {
|
||||
}
|
||||
|
||||
public var borderColor:UIColor = UIColor(red: 204.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0){
|
||||
didSet{ dtLayer.borderColor = borderColor.cgColor }
|
||||
didSet{
|
||||
switch dtborderStyle {
|
||||
case .none,.rounded,.sqare:
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
case .bottom,.right,.top,.left:
|
||||
borderLayer.backgroundColor = borderColor.cgColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var canShowBorder:Bool = true{
|
||||
didSet{ dtLayer.isHidden = !canShowBorder }
|
||||
didSet{
|
||||
switch dtborderStyle {
|
||||
case .none,.rounded,.sqare:
|
||||
dtLayer.isHidden = !canShowBorder
|
||||
case .bottom,.right,.top,.left:
|
||||
borderLayer.isHidden = !canShowBorder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var placeholderColor:UIColor?{
|
||||
didSet{
|
||||
guard let color = placeholderColor else { return }
|
||||
attributedPlaceholder = NSAttributedString(string: placeholderFinal,
|
||||
attributes: [NSForegroundColorAttributeName:color])
|
||||
attributes: [NSAttributedString.Key.foregroundColor:color])
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate var x:CGFloat {
|
||||
|
||||
if let leftView = leftView {
|
||||
return leftView.frame.origin.x + leftView.bounds.size.width + paddingX
|
||||
return leftView.frame.origin.x + leftView.bounds.size.width - paddingX
|
||||
}
|
||||
|
||||
return paddingX
|
||||
@@ -130,13 +199,17 @@ public class DTTextField: UITextField {
|
||||
}
|
||||
}
|
||||
|
||||
override public var borderStyle: UITextBorderStyle{
|
||||
override public var borderStyle: UITextField.BorderStyle{
|
||||
didSet{
|
||||
guard borderStyle != oldValue else { return }
|
||||
borderStyle = .none
|
||||
}
|
||||
}
|
||||
|
||||
public override var textAlignment: NSTextAlignment{
|
||||
didSet{ setNeedsLayout() }
|
||||
}
|
||||
|
||||
public override var text: String?{
|
||||
didSet{ self.textFieldTextChanged() }
|
||||
}
|
||||
@@ -149,7 +222,7 @@ public class DTTextField: UITextField {
|
||||
return
|
||||
}
|
||||
attributedPlaceholder = NSAttributedString(string: placeholderFinal,
|
||||
attributes: [NSForegroundColorAttributeName:color])
|
||||
attributes: [NSAttributedString.Key.foregroundColor:color])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,11 +249,10 @@ public class DTTextField: UITextField {
|
||||
showErrorLabel = false
|
||||
}
|
||||
|
||||
|
||||
fileprivate func commonInit() {
|
||||
|
||||
dtLayer.cornerRadius = 4.5
|
||||
dtLayer.borderWidth = 0.5
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
dtborderStyle = .rounded
|
||||
dtLayer.backgroundColor = UIColor.white.cgColor
|
||||
|
||||
floatPlaceholderColor = UIColor(red: 204.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0)
|
||||
@@ -209,12 +281,52 @@ public class DTTextField: UITextField {
|
||||
|
||||
lblError.text = errorMessage
|
||||
lblError.isHidden = false
|
||||
let boundWithPadding = CGSize(width: bounds.width - (x * 2), height: bounds.height)
|
||||
let errorLabelSize = lblError.sizeThatFits(boundWithPadding)
|
||||
lblError.frame = CGRect(x: paddingX, y: 0, width: errorLabelSize.width, height: errorLabelSize.height)
|
||||
let boundWithPadding = CGSize(width: bounds.width - (paddingX * 2), height: bounds.height)
|
||||
lblError.frame = CGRect(x: paddingX, y: 0, width: boundWithPadding.width, height: boundWithPadding.height)
|
||||
lblError.sizeToFit()
|
||||
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
func setErrorLabelAlignment() {
|
||||
var newFrame = lblError.frame
|
||||
|
||||
if textAlignment == .right {
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}else if textAlignment == .left{
|
||||
newFrame.origin.x = paddingX
|
||||
}else if textAlignment == .center{
|
||||
newFrame.origin.x = (bounds.width / 2.0) - (newFrame.size.width / 2.0)
|
||||
}else if textAlignment == .natural{
|
||||
|
||||
if UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft{
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}
|
||||
}
|
||||
|
||||
lblError.frame = newFrame
|
||||
}
|
||||
|
||||
func setFloatLabelAlignment() {
|
||||
var newFrame = lblFloatPlaceholder.frame
|
||||
|
||||
if textAlignment == .right {
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}else if textAlignment == .left{
|
||||
newFrame.origin.x = paddingX
|
||||
}else if textAlignment == .center{
|
||||
newFrame.origin.x = (bounds.width / 2.0) - (newFrame.size.width / 2.0)
|
||||
}else if textAlignment == .natural{
|
||||
|
||||
if UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft{
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lblFloatPlaceholder.frame = newFrame
|
||||
}
|
||||
|
||||
fileprivate func hideErrorMessage(){
|
||||
lblError.text = ""
|
||||
lblError.isHidden = true
|
||||
@@ -271,18 +383,20 @@ public class DTTextField: UITextField {
|
||||
}
|
||||
|
||||
fileprivate func insetRectForEmptyBounds(rect:CGRect) -> CGRect{
|
||||
|
||||
guard showErrorLabel else { return CGRect(x: x, y: 0, width: rect.width - paddingX, height: rect.height) }
|
||||
let newX = x
|
||||
guard showErrorLabel else { return CGRect(x: newX, y: 0, width: rect.width - newX - paddingX, height: rect.height) }
|
||||
|
||||
let topInset = (rect.size.height - lblError.bounds.size.height - paddingYErrorLabel - fontHeight) / 2.0
|
||||
let textY = topInset - ((rect.height - fontHeight) / 2.0)
|
||||
|
||||
return CGRect(x: x, y: floor(textY), width: rect.size.width - paddingX, height: rect.size.height)
|
||||
return CGRect(x: newX, y: floor(textY), width: rect.size.width - newX - paddingX, height: rect.size.height)
|
||||
}
|
||||
|
||||
fileprivate func insetRectForBounds(rect:CGRect) -> CGRect {
|
||||
|
||||
guard !lblFloatPlaceholder.text!.isEmptyStr else { return insetRectForEmptyBounds(rect: rect) }
|
||||
guard let placeholderText = lblFloatPlaceholder.text,!placeholderText.isEmptyStr else {
|
||||
return insetRectForEmptyBounds(rect: rect)
|
||||
}
|
||||
|
||||
if floatingDisplayStatus == .never {
|
||||
return insetRectForEmptyBounds(rect: rect)
|
||||
@@ -295,9 +409,9 @@ public class DTTextField: UITextField {
|
||||
let textOriginalY = (rect.height - fontHeight) / 2.0
|
||||
var textY = topInset - textOriginalY
|
||||
|
||||
if textY < 0 { textY = topInset }
|
||||
|
||||
return CGRect(x: x, y: ceil(textY), width: rect.size.width - paddingX, height: rect.height)
|
||||
if textY < 0 && !showErrorLabel { textY = topInset }
|
||||
let newX = x
|
||||
return CGRect(x: newX, y: ceil(textY), width: rect.size.width - newX - paddingX, height: rect.height)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -312,8 +426,6 @@ public class DTTextField: UITextField {
|
||||
|
||||
let textFieldIntrinsicContentSize = super.intrinsicContentSize
|
||||
|
||||
lblError.sizeToFit()
|
||||
|
||||
if showErrorLabel {
|
||||
lblFloatPlaceholder.sizeToFit()
|
||||
return CGSize(width: textFieldIntrinsicContentSize.width,
|
||||
@@ -366,6 +478,8 @@ public class DTTextField: UITextField {
|
||||
y: bounds.origin.y,
|
||||
width: bounds.width,
|
||||
height: dtLayerHeight)
|
||||
let borderStype = dtborderStyle
|
||||
dtborderStyle = borderStype
|
||||
CATransaction.commit()
|
||||
|
||||
if showErrorLabel {
|
||||
@@ -381,6 +495,8 @@ public class DTTextField: UITextField {
|
||||
width: floatingLabelSize.width,
|
||||
height: floatingLabelSize.height)
|
||||
|
||||
setErrorLabelAlignment()
|
||||
setFloatLabelAlignment()
|
||||
lblFloatPlaceholder.textColor = isFirstResponder ? floatPlaceholderActiveColor : floatPlaceholderColor
|
||||
|
||||
switch floatingDisplayStatus {
|
||||
@@ -396,4 +512,5 @@ public class DTTextField: UITextField {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
0EBDB911205BD7EA001E212E /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 0EBDB90F205BD7EA001E212E /* Localizable.strings */; };
|
||||
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; };
|
||||
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD71AFB9204008FA782 /* ViewController.swift */; };
|
||||
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; };
|
||||
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
|
||||
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
|
||||
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
|
||||
7CBDD22C174BE4A9D62F0838 /* Pods_DTTextField_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F0D037025A52EC73A143FA2 /* Pods_DTTextField_Example.framework */; };
|
||||
F3B670DD4D60B75D53BF34AB /* Pods_DTTextField_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A73FFAC2C238F6E99F680420 /* Pods_DTTextField_Tests.framework */; };
|
||||
F20EFAF71ED7136A00DE8008 /* DTTextField.swift in Sources */ = {isa = PBXBuildFile; fileRef = F20EFAF61ED7136A00DE8008 /* DTTextField.swift */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@@ -28,10 +28,10 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
060B7103A3E600F8B2BD7D22 /* Pods-DTTextField_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DTTextField_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DTTextField_Example/Pods-DTTextField_Example.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
2C22D21F3A2AE3ADC3442B4C /* Pods-DTTextField_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DTTextField_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-DTTextField_Tests/Pods-DTTextField_Tests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
4F0D037025A52EC73A143FA2 /* Pods_DTTextField_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DTTextField_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
5B7FD7AC92A60AFDB02B68F9 /* Pods-DTTextField_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DTTextField_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-DTTextField_Example/Pods-DTTextField_Example.release.xcconfig"; sourceTree = "<group>"; };
|
||||
0EBDB903205BCB1C001E212E /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Main.strings; sourceTree = "<group>"; };
|
||||
0EBDB904205BCB1C001E212E /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/LaunchScreen.strings; sourceTree = "<group>"; };
|
||||
0EBDB912205BD7EE001E212E /* Base */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = Base; path = Base.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
0EBDB915205BD839001E212E /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||
607FACD01AFB9204008FA782 /* DTTextField_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DTTextField_Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
@@ -42,8 +42,7 @@
|
||||
607FACE51AFB9204008FA782 /* DTTextField_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DTTextField_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
|
||||
9DCF83E02A68CA6BD5E2E2CF /* Pods-DTTextField_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DTTextField_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DTTextField_Tests/Pods-DTTextField_Tests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
A73FFAC2C238F6E99F680420 /* Pods_DTTextField_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DTTextField_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F20EFAF61ED7136A00DE8008 /* DTTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DTTextField.swift; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -51,7 +50,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7CBDD22C174BE4A9D62F0838 /* Pods_DTTextField_Example.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -59,41 +57,18 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F3B670DD4D60B75D53BF34AB /* Pods_DTTextField_Tests.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
0AA3E72CF6526EF5C790DC68 /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
060B7103A3E600F8B2BD7D22 /* Pods-DTTextField_Example.debug.xcconfig */,
|
||||
5B7FD7AC92A60AFDB02B68F9 /* Pods-DTTextField_Example.release.xcconfig */,
|
||||
9DCF83E02A68CA6BD5E2E2CF /* Pods-DTTextField_Tests.debug.xcconfig */,
|
||||
2C22D21F3A2AE3ADC3442B4C /* Pods-DTTextField_Tests.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3D2E65FC1F3555D9D00626A6 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
4F0D037025A52EC73A143FA2 /* Pods_DTTextField_Example.framework */,
|
||||
A73FFAC2C238F6E99F680420 /* Pods_DTTextField_Tests.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACC71AFB9204008FA782 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACD21AFB9204008FA782 /* Example for DTTextField */,
|
||||
607FACE81AFB9204008FA782 /* Tests */,
|
||||
607FACD11AFB9204008FA782 /* Products */,
|
||||
0AA3E72CF6526EF5C790DC68 /* Pods */,
|
||||
3D2E65FC1F3555D9D00626A6 /* Frameworks */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
@@ -109,6 +84,8 @@
|
||||
607FACD21AFB9204008FA782 /* Example for DTTextField */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0EBDB90F205BD7EA001E212E /* Localizable.strings */,
|
||||
F20EFAF61ED7136A00DE8008 /* DTTextField.swift */,
|
||||
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
|
||||
607FACD71AFB9204008FA782 /* ViewController.swift */,
|
||||
607FACD91AFB9204008FA782 /* Main.storyboard */,
|
||||
@@ -152,12 +129,9 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "DTTextField_Example" */;
|
||||
buildPhases = (
|
||||
8D9A9A1AA162783013888FFF /* [CP] Check Pods Manifest.lock */,
|
||||
607FACCC1AFB9204008FA782 /* Sources */,
|
||||
607FACCD1AFB9204008FA782 /* Frameworks */,
|
||||
607FACCE1AFB9204008FA782 /* Resources */,
|
||||
EEDC89F8840910979DA52450 /* [CP] Embed Pods Frameworks */,
|
||||
11408D7F6D7029447C5C8ADF /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -172,12 +146,9 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "DTTextField_Tests" */;
|
||||
buildPhases = (
|
||||
30328B87BF196F8639A96E90 /* [CP] Check Pods Manifest.lock */,
|
||||
607FACE11AFB9204008FA782 /* Sources */,
|
||||
607FACE21AFB9204008FA782 /* Frameworks */,
|
||||
607FACE31AFB9204008FA782 /* Resources */,
|
||||
E8431CE4674170545D9AD7F5 /* [CP] Embed Pods Frameworks */,
|
||||
2A1C3BCADED2085C775AC86D /* [CP] Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -201,6 +172,7 @@
|
||||
TargetAttributes = {
|
||||
607FACCF1AFB9204008FA782 = {
|
||||
CreatedOnToolsVersion = 6.3.1;
|
||||
DevelopmentTeam = XDZ4VN9T5R;
|
||||
LastSwiftMigration = 0820;
|
||||
};
|
||||
607FACE41AFB9204008FA782 = {
|
||||
@@ -215,8 +187,10 @@
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
English,
|
||||
en,
|
||||
Base,
|
||||
ar,
|
||||
);
|
||||
mainGroup = 607FACC71AFB9204008FA782;
|
||||
productRefGroup = 607FACD11AFB9204008FA782 /* Products */;
|
||||
@@ -235,6 +209,7 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
|
||||
0EBDB911205BD7EA001E212E /* Localizable.strings in Resources */,
|
||||
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
|
||||
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
|
||||
);
|
||||
@@ -249,104 +224,12 @@
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
11408D7F6D7029447C5C8ADF /* [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-DTTextField_Example/Pods-DTTextField_Example-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
2A1C3BCADED2085C775AC86D /* [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-DTTextField_Tests/Pods-DTTextField_Tests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
30328B87BF196F8639A96E90 /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
8D9A9A1AA162783013888FFF /* [CP] Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
E8431CE4674170545D9AD7F5 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DTTextField_Tests/Pods-DTTextField_Tests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
EEDC89F8840910979DA52450 /* [CP] Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DTTextField_Example/Pods-DTTextField_Example-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
607FACCC1AFB9204008FA782 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F20EFAF71ED7136A00DE8008 /* DTTextField.swift in Sources */,
|
||||
607FACD81AFB9204008FA782 /* ViewController.swift in Sources */,
|
||||
607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */,
|
||||
);
|
||||
@@ -371,10 +254,20 @@
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin PBXVariantGroup section */
|
||||
0EBDB90F205BD7EA001E212E /* Localizable.strings */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
0EBDB912205BD7EE001E212E /* Base */,
|
||||
0EBDB915205BD839001E212E /* ar */,
|
||||
);
|
||||
name = Localizable.strings;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACD91AFB9204008FA782 /* Main.storyboard */ = {
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
607FACDA1AFB9204008FA782 /* Base */,
|
||||
0EBDB903205BCB1C001E212E /* ar */,
|
||||
);
|
||||
name = Main.storyboard;
|
||||
sourceTree = "<group>";
|
||||
@@ -383,6 +276,7 @@
|
||||
isa = PBXVariantGroup;
|
||||
children = (
|
||||
607FACDF1AFB9204008FA782 /* Base */,
|
||||
0EBDB904205BCB1C001E212E /* ar */,
|
||||
);
|
||||
name = LaunchScreen.xib;
|
||||
sourceTree = "<group>";
|
||||
@@ -394,6 +288,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -441,6 +336,7 @@
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
@@ -479,37 +375,36 @@
|
||||
};
|
||||
607FACF01AFB9204008FA782 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 060B7103A3E600F8B2BD7D22 /* Pods-DTTextField_Example.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
DEVELOPMENT_TEAM = XDZ4VN9T5R;
|
||||
INFOPLIST_FILE = DTTextField/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.DTTextField-Example1";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
607FACF11AFB9204008FA782 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 5B7FD7AC92A60AFDB02B68F9 /* Pods-DTTextField_Example.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
DEVELOPMENT_TEAM = XDZ4VN9T5R;
|
||||
INFOPLIST_FILE = DTTextField/Info.plist;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MODULE_NAME = ExampleApp;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.DTTextField-Example1";
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_VERSION = 3.0;
|
||||
SWIFT_VERSION = 5.0;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
607FACF31AFB9204008FA782 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9DCF83E02A68CA6BD5E2E2CF /* Pods-DTTextField_Tests.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
@@ -529,7 +424,6 @@
|
||||
};
|
||||
607FACF41AFB9204008FA782 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 2C22D21F3A2AE3ADC3442B4C /* Pods-DTTextField_Tests.release.xcconfig */;
|
||||
buildSettings = {
|
||||
FRAMEWORK_SEARCH_PATHS = (
|
||||
"$(SDKROOT)/Developer/Library/Frameworks",
|
||||
|
||||
@@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
|
||||
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Arabic.strings
|
||||
DTTextField
|
||||
|
||||
Created by Dhaval Thanki on 16/03/18.
|
||||
Copyright © 2018 CocoaPods. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16C67" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Kzc-T6-rcN">
|
||||
<device id="retina4_7" orientation="portrait">
|
||||
<adaptation id="fullscreen"/>
|
||||
</device>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="15505" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Kzc-T6-rcN">
|
||||
<device id="retina4_7" orientation="portrait" appearance="light"/>
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
|
||||
<deployment identifier="iOS"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15509"/>
|
||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
@@ -21,69 +20,64 @@
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3qx-l3-jfU">
|
||||
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
|
||||
<rect key="frame" x="0.0" y="44" width="375" height="623"/>
|
||||
<subviews>
|
||||
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="T5N-VG-n0n">
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="332"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="375" height="623"/>
|
||||
<subviews>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="First Name" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="LZk-sC-XSt" customClass="DTTextField" customModule="DTTextField">
|
||||
<rect key="frame" x="16" y="50" width="343" height="30"/>
|
||||
<nil key="textColor"/>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="First Name" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="LZk-sC-XSt" customClass="DTTextField" customModule="DTTextField_Example" customModuleProvider="target">
|
||||
<rect key="frame" x="16" y="50" width="343" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Last Name" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ZMK-KE-9Cc" customClass="DTTextField" customModule="DTTextField">
|
||||
<rect key="frame" x="16" y="88" width="343" height="30"/>
|
||||
<nil key="textColor"/>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Last Name" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="ZMK-KE-9Cc" customClass="DTTextField" customModule="DTTextField_Example" customModuleProvider="target">
|
||||
<rect key="frame" x="16" y="92" width="343" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Email" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="6gk-3f-Yz6" customClass="DTTextField" customModule="DTTextField">
|
||||
<rect key="frame" x="16" y="126" width="343" height="30"/>
|
||||
<nil key="textColor"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="63c-z6-Pat" customClass="DTTextField" customModule="DTTextField">
|
||||
<rect key="frame" x="16" y="164" width="343" height="30"/>
|
||||
<nil key="textColor"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
|
||||
</textField>
|
||||
<textField opaque="NO" clipsSubviews="YES" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Confirm Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="zBn-BA-f2Y" customClass="DTTextField" customModule="DTTextField">
|
||||
<rect key="frame" x="16" y="202" width="343" height="30"/>
|
||||
<nil key="textColor"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" secureTextEntry="YES"/>
|
||||
</textField>
|
||||
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Vp4-XI-7k7">
|
||||
<rect key="frame" x="158.5" y="267" width="57" height="30"/>
|
||||
<rect key="frame" x="159" y="262" width="57" height="30"/>
|
||||
<state key="normal" title="Register"/>
|
||||
<connections>
|
||||
<action selector="onBtnSubmitClicked:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="vbi-gx-VFd"/>
|
||||
</connections>
|
||||
</button>
|
||||
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Email" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="G8b-0H-NOp" customClass="DTTextField" customModule="DTTextField_Example" customModuleProvider="target">
|
||||
<rect key="frame" x="16" y="134" width="343" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="vOV-P3-5my" customClass="DTTextField" customModule="DTTextField_Example" customModuleProvider="target">
|
||||
<rect key="frame" x="16" y="176" width="343" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
<textField opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="Confirm Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="oVW-xu-ETH" customClass="DTTextField" customModule="DTTextField_Example" customModuleProvider="target">
|
||||
<rect key="frame" x="16" y="218" width="343" height="34"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits"/>
|
||||
</textField>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<constraints>
|
||||
<constraint firstItem="oVW-xu-ETH" firstAttribute="trailing" secondItem="vOV-P3-5my" secondAttribute="trailing" id="2Eh-Ef-dQi"/>
|
||||
<constraint firstItem="oVW-xu-ETH" firstAttribute="leading" secondItem="vOV-P3-5my" secondAttribute="leading" id="2iy-n5-w9F"/>
|
||||
<constraint firstAttribute="trailing" secondItem="LZk-sC-XSt" secondAttribute="trailing" constant="16" id="7xF-Yy-7dc"/>
|
||||
<constraint firstItem="LZk-sC-XSt" firstAttribute="leading" secondItem="T5N-VG-n0n" secondAttribute="leading" constant="16" id="8fK-In-ELG"/>
|
||||
<constraint firstItem="zBn-BA-f2Y" firstAttribute="trailing" secondItem="63c-z6-Pat" secondAttribute="trailing" id="BhC-IN-UKU"/>
|
||||
<constraint firstItem="zBn-BA-f2Y" firstAttribute="top" secondItem="63c-z6-Pat" secondAttribute="bottom" constant="8" id="Cwc-4p-Bbi"/>
|
||||
<constraint firstItem="6gk-3f-Yz6" firstAttribute="leading" secondItem="ZMK-KE-9Cc" secondAttribute="leading" id="E56-qn-ZL2"/>
|
||||
<constraint firstAttribute="bottom" secondItem="Vp4-XI-7k7" secondAttribute="bottom" constant="35" id="HWJ-ke-SwV"/>
|
||||
<constraint firstItem="G8b-0H-NOp" firstAttribute="top" secondItem="ZMK-KE-9Cc" secondAttribute="bottom" constant="8" id="9MY-nz-wjQ"/>
|
||||
<constraint firstItem="vOV-P3-5my" firstAttribute="trailing" secondItem="G8b-0H-NOp" secondAttribute="trailing" id="BZ6-is-x2y"/>
|
||||
<constraint firstItem="Vp4-XI-7k7" firstAttribute="top" secondItem="oVW-xu-ETH" secondAttribute="bottom" constant="10" id="Czg-UB-G6G"/>
|
||||
<constraint firstItem="vOV-P3-5my" firstAttribute="leading" secondItem="G8b-0H-NOp" secondAttribute="leading" id="FlG-Yh-6D8"/>
|
||||
<constraint firstAttribute="bottom" relation="greaterThanOrEqual" secondItem="Vp4-XI-7k7" secondAttribute="bottom" constant="35" id="HWJ-ke-SwV"/>
|
||||
<constraint firstItem="ZMK-KE-9Cc" firstAttribute="leading" secondItem="LZk-sC-XSt" secondAttribute="leading" id="Jzj-d1-Cuc"/>
|
||||
<constraint firstItem="63c-z6-Pat" firstAttribute="leading" secondItem="6gk-3f-Yz6" secondAttribute="leading" id="OjR-tc-La6"/>
|
||||
<constraint firstItem="G8b-0H-NOp" firstAttribute="leading" secondItem="ZMK-KE-9Cc" secondAttribute="leading" id="X9C-jl-FiE"/>
|
||||
<constraint firstItem="ZMK-KE-9Cc" firstAttribute="top" secondItem="LZk-sC-XSt" secondAttribute="bottom" constant="8" id="XKP-xw-pz9"/>
|
||||
<constraint firstItem="63c-z6-Pat" firstAttribute="trailing" secondItem="6gk-3f-Yz6" secondAttribute="trailing" id="YEb-NT-sFz"/>
|
||||
<constraint firstItem="6gk-3f-Yz6" firstAttribute="top" secondItem="ZMK-KE-9Cc" secondAttribute="bottom" constant="8" id="Z08-RU-aXk"/>
|
||||
<constraint firstItem="6gk-3f-Yz6" firstAttribute="trailing" secondItem="ZMK-KE-9Cc" secondAttribute="trailing" id="a2N-wr-VXy"/>
|
||||
<constraint firstItem="63c-z6-Pat" firstAttribute="top" secondItem="6gk-3f-Yz6" secondAttribute="bottom" constant="8" id="aPM-Xo-bCc"/>
|
||||
<constraint firstItem="oVW-xu-ETH" firstAttribute="top" secondItem="vOV-P3-5my" secondAttribute="bottom" constant="8" id="eEv-lG-Ktc"/>
|
||||
<constraint firstItem="Vp4-XI-7k7" firstAttribute="centerX" secondItem="T5N-VG-n0n" secondAttribute="centerX" id="ikl-qL-tO7"/>
|
||||
<constraint firstItem="G8b-0H-NOp" firstAttribute="trailing" secondItem="ZMK-KE-9Cc" secondAttribute="trailing" id="onN-5k-UBd"/>
|
||||
<constraint firstItem="LZk-sC-XSt" firstAttribute="top" secondItem="T5N-VG-n0n" secondAttribute="top" constant="50" id="pmI-vf-fOU"/>
|
||||
<constraint firstItem="Vp4-XI-7k7" firstAttribute="centerX" secondItem="zBn-BA-f2Y" secondAttribute="centerX" id="qqR-IB-W1J"/>
|
||||
<constraint firstItem="ZMK-KE-9Cc" firstAttribute="trailing" secondItem="LZk-sC-XSt" secondAttribute="trailing" id="tZs-73-KYu"/>
|
||||
<constraint firstItem="zBn-BA-f2Y" firstAttribute="leading" secondItem="63c-z6-Pat" secondAttribute="leading" id="wde-fS-5eM"/>
|
||||
<constraint firstItem="Vp4-XI-7k7" firstAttribute="top" secondItem="zBn-BA-f2Y" secondAttribute="bottom" constant="35" id="xHo-6Z-Xaa"/>
|
||||
<constraint firstItem="vOV-P3-5my" firstAttribute="top" secondItem="G8b-0H-NOp" secondAttribute="bottom" constant="8" id="xmr-Ec-n2N"/>
|
||||
</constraints>
|
||||
</view>
|
||||
</subviews>
|
||||
@@ -108,16 +102,16 @@
|
||||
<navigationItem key="navigationItem" id="W1x-bm-hbZ"/>
|
||||
<connections>
|
||||
<outlet property="scrollView" destination="3qx-l3-jfU" id="Wim-19-5FL"/>
|
||||
<outlet property="txtConfirmPassword" destination="zBn-BA-f2Y" id="kBp-NH-lSI"/>
|
||||
<outlet property="txtEmail" destination="6gk-3f-Yz6" id="0vh-rG-4OR"/>
|
||||
<outlet property="txtConfirmPassword" destination="oVW-xu-ETH" id="tc3-xT-Cq0"/>
|
||||
<outlet property="txtEmail" destination="G8b-0H-NOp" id="roZ-B7-YhX"/>
|
||||
<outlet property="txtFirstName" destination="LZk-sC-XSt" id="gxg-Mj-Ljm"/>
|
||||
<outlet property="txtLastName" destination="ZMK-KE-9Cc" id="bQS-O5-38P"/>
|
||||
<outlet property="txtPassword" destination="63c-z6-Pat" id="gjV-fO-CFS"/>
|
||||
<outlet property="txtPassword" destination="vOV-P3-5my" id="9Id-na-8eO"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="964" y="36.431784107946029"/>
|
||||
<point key="canvasLocation" x="554" y="46"/>
|
||||
</scene>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="sQ1-e3-OIZ">
|
||||
@@ -135,7 +129,7 @@
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="qlg-7C-Sy0" userLabel="First Responder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="122" y="36"/>
|
||||
<point key="canvasLocation" x="-194" y="47"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
||||
|
||||
@@ -0,0 +1,516 @@
|
||||
//
|
||||
// DTTextField.swift
|
||||
// Pods
|
||||
//
|
||||
// Created by Dhaval Thanki on 03/04/17.
|
||||
//
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public extension String {
|
||||
|
||||
var isEmptyStr:Bool{
|
||||
return self.trimmingCharacters(in: NSCharacterSet.whitespaces).isEmpty
|
||||
}
|
||||
}
|
||||
|
||||
public class DTTextField: UITextField {
|
||||
|
||||
public enum FloatingDisplayStatus{
|
||||
case always
|
||||
case never
|
||||
case defaults
|
||||
}
|
||||
|
||||
public enum DTBorderStyle{
|
||||
case none
|
||||
case rounded
|
||||
case sqare
|
||||
case top
|
||||
case bottom
|
||||
case left
|
||||
case right
|
||||
}
|
||||
|
||||
fileprivate var lblFloatPlaceholder:UILabel = UILabel()
|
||||
fileprivate var lblError:UILabel = UILabel()
|
||||
|
||||
fileprivate let paddingX:CGFloat = 5.0
|
||||
|
||||
fileprivate let paddingHeight:CGFloat = 10.0
|
||||
fileprivate var borderLayer:CALayer = CALayer()
|
||||
public var dtLayer:CALayer = CALayer()
|
||||
public var floatPlaceholderColor:UIColor = UIColor.black
|
||||
public var floatPlaceholderActiveColor:UIColor = UIColor.black
|
||||
public var floatingLabelShowAnimationDuration = 0.3
|
||||
public var floatingDisplayStatus:FloatingDisplayStatus = .defaults
|
||||
public var borderWidth:CGFloat = 0.5{
|
||||
didSet{
|
||||
let borderStyle = dtborderStyle;
|
||||
dtborderStyle = borderStyle
|
||||
}
|
||||
}
|
||||
|
||||
public var dtborderStyle:DTBorderStyle = .rounded{
|
||||
didSet{
|
||||
borderLayer.removeFromSuperlayer()
|
||||
switch dtborderStyle {
|
||||
case .none:
|
||||
dtLayer.cornerRadius = 0.0
|
||||
dtLayer.borderWidth = 0.0
|
||||
case .rounded:
|
||||
dtLayer.cornerRadius = 4.5
|
||||
dtLayer.borderWidth = borderWidth
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
case .sqare:
|
||||
dtLayer.cornerRadius = 0.0
|
||||
dtLayer.borderWidth = borderWidth
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
case .bottom,.left,.right,.top:
|
||||
dtLayer.cornerRadius = 0.0
|
||||
dtLayer.borderWidth = 0.0
|
||||
borderLayer.backgroundColor = borderColor.cgColor
|
||||
if dtborderStyle == .bottom {
|
||||
borderLayer.frame = CGRect(x: 0, y: dtLayer.bounds.size.height - borderWidth, width: dtLayer.bounds.size.width, height: borderWidth)
|
||||
}else if dtborderStyle == .left{
|
||||
borderLayer.frame = CGRect(x: 0, y: 0, width: borderWidth, height: dtLayer.bounds.size.height)
|
||||
}else if dtborderStyle == .right{
|
||||
borderLayer.frame = CGRect(x: dtLayer.bounds.size.width - borderWidth, y: 0, width: borderWidth, height: dtLayer.bounds.size.height)
|
||||
}else{
|
||||
borderLayer.frame = CGRect(x: 0, y: 0, width: dtLayer.bounds.size.width, height: borderWidth)
|
||||
}
|
||||
dtLayer.addSublayer(borderLayer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var errorMessage:String = ""{
|
||||
didSet{ lblError.text = errorMessage }
|
||||
}
|
||||
|
||||
public var animateFloatPlaceholder:Bool = true
|
||||
public var hideErrorWhenEditing:Bool = true
|
||||
|
||||
public var errorFont = UIFont.systemFont(ofSize: 10.0){
|
||||
didSet{
|
||||
lblError.font = errorFont
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
}
|
||||
|
||||
public var floatPlaceholderFont = UIFont.systemFont(ofSize: 10.0){
|
||||
didSet{
|
||||
lblFloatPlaceholder.font = floatPlaceholderFont
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
}
|
||||
|
||||
public var paddingYFloatLabel:CGFloat = 3.0{
|
||||
didSet{ invalidateIntrinsicContentSize() }
|
||||
}
|
||||
|
||||
public var paddingYErrorLabel:CGFloat = 3.0{
|
||||
didSet{ invalidateIntrinsicContentSize() }
|
||||
}
|
||||
|
||||
public var borderColor:UIColor = UIColor(red: 204.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0){
|
||||
didSet{
|
||||
switch dtborderStyle {
|
||||
case .none,.rounded,.sqare:
|
||||
dtLayer.borderColor = borderColor.cgColor
|
||||
case .bottom,.right,.top,.left:
|
||||
borderLayer.backgroundColor = borderColor.cgColor
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var canShowBorder:Bool = true{
|
||||
didSet{
|
||||
switch dtborderStyle {
|
||||
case .none,.rounded,.sqare:
|
||||
dtLayer.isHidden = !canShowBorder
|
||||
case .bottom,.right,.top,.left:
|
||||
borderLayer.isHidden = !canShowBorder
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public var placeholderColor:UIColor?{
|
||||
didSet{
|
||||
guard let color = placeholderColor else { return }
|
||||
attributedPlaceholder = NSAttributedString(string: placeholderFinal,
|
||||
attributes: [NSAttributedString.Key.foregroundColor:color])
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate var x:CGFloat {
|
||||
|
||||
if let leftView = leftView {
|
||||
return leftView.frame.origin.x + leftView.bounds.size.width - paddingX
|
||||
}
|
||||
|
||||
return paddingX
|
||||
}
|
||||
|
||||
fileprivate var fontHeight:CGFloat{
|
||||
return ceil(font!.lineHeight)
|
||||
}
|
||||
|
||||
fileprivate var dtLayerHeight:CGFloat{
|
||||
return showErrorLabel ? floor(bounds.height - lblError.bounds.size.height - paddingYErrorLabel) : bounds.height
|
||||
}
|
||||
|
||||
fileprivate var floatLabelWidth:CGFloat{
|
||||
|
||||
var width = bounds.size.width
|
||||
|
||||
if let leftViewWidth = leftView?.bounds.size.width{
|
||||
width -= leftViewWidth
|
||||
}
|
||||
|
||||
if let rightViewWidth = rightView?.bounds.size.width {
|
||||
width -= rightViewWidth
|
||||
}
|
||||
|
||||
return width - (self.x * 2)
|
||||
}
|
||||
|
||||
fileprivate var placeholderFinal:String{
|
||||
if let attributed = attributedPlaceholder { return attributed.string }
|
||||
return placeholder ?? " "
|
||||
}
|
||||
|
||||
fileprivate var isFloatLabelShowing:Bool = false
|
||||
|
||||
fileprivate var showErrorLabel:Bool = false{
|
||||
didSet{
|
||||
|
||||
guard showErrorLabel != oldValue else { return }
|
||||
|
||||
guard showErrorLabel else {
|
||||
hideErrorMessage()
|
||||
return
|
||||
}
|
||||
|
||||
guard !errorMessage.isEmptyStr else { return }
|
||||
showErrorMessage()
|
||||
}
|
||||
}
|
||||
|
||||
override public var borderStyle: UITextField.BorderStyle{
|
||||
didSet{
|
||||
guard borderStyle != oldValue else { return }
|
||||
borderStyle = .none
|
||||
}
|
||||
}
|
||||
|
||||
public override var textAlignment: NSTextAlignment{
|
||||
didSet{ setNeedsLayout() }
|
||||
}
|
||||
|
||||
public override var text: String?{
|
||||
didSet{ self.textFieldTextChanged() }
|
||||
}
|
||||
|
||||
override public var placeholder: String?{
|
||||
didSet{
|
||||
|
||||
guard let color = placeholderColor else {
|
||||
lblFloatPlaceholder.text = placeholderFinal
|
||||
return
|
||||
}
|
||||
attributedPlaceholder = NSAttributedString(string: placeholderFinal,
|
||||
attributes: [NSAttributedString.Key.foregroundColor:color])
|
||||
}
|
||||
}
|
||||
|
||||
override public var attributedPlaceholder: NSAttributedString?{
|
||||
didSet{ lblFloatPlaceholder.text = placeholderFinal }
|
||||
}
|
||||
|
||||
override public init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
commonInit()
|
||||
}
|
||||
|
||||
public func showError(message:String? = nil) {
|
||||
if let msg = message { errorMessage = msg }
|
||||
showErrorLabel = true
|
||||
}
|
||||
|
||||
public func hideError() {
|
||||
showErrorLabel = false
|
||||
}
|
||||
|
||||
|
||||
fileprivate func commonInit() {
|
||||
|
||||
dtborderStyle = .rounded
|
||||
dtLayer.backgroundColor = UIColor.white.cgColor
|
||||
|
||||
floatPlaceholderColor = UIColor(red: 204.0/255.0, green: 204.0/255.0, blue: 204.0/255.0, alpha: 1.0)
|
||||
floatPlaceholderActiveColor = tintColor
|
||||
lblFloatPlaceholder.frame = CGRect.zero
|
||||
lblFloatPlaceholder.alpha = 0.0
|
||||
lblFloatPlaceholder.font = floatPlaceholderFont
|
||||
lblFloatPlaceholder.text = placeholderFinal
|
||||
|
||||
addSubview(lblFloatPlaceholder)
|
||||
|
||||
lblError.frame = CGRect.zero
|
||||
lblError.font = errorFont
|
||||
lblError.textColor = UIColor.red
|
||||
lblError.numberOfLines = 0
|
||||
lblError.isHidden = true
|
||||
|
||||
addTarget(self, action: #selector(textFieldTextChanged), for: .editingChanged)
|
||||
|
||||
addSubview(lblError)
|
||||
|
||||
layer.insertSublayer(dtLayer, at: 0)
|
||||
}
|
||||
|
||||
fileprivate func showErrorMessage(){
|
||||
|
||||
lblError.text = errorMessage
|
||||
lblError.isHidden = false
|
||||
let boundWithPadding = CGSize(width: bounds.width - (paddingX * 2), height: bounds.height)
|
||||
lblError.frame = CGRect(x: paddingX, y: 0, width: boundWithPadding.width, height: boundWithPadding.height)
|
||||
lblError.sizeToFit()
|
||||
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
func setErrorLabelAlignment() {
|
||||
var newFrame = lblError.frame
|
||||
|
||||
if textAlignment == .right {
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}else if textAlignment == .left{
|
||||
newFrame.origin.x = paddingX
|
||||
}else if textAlignment == .center{
|
||||
newFrame.origin.x = (bounds.width / 2.0) - (newFrame.size.width / 2.0)
|
||||
}else if textAlignment == .natural{
|
||||
|
||||
if UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft{
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}
|
||||
}
|
||||
|
||||
lblError.frame = newFrame
|
||||
}
|
||||
|
||||
func setFloatLabelAlignment() {
|
||||
var newFrame = lblFloatPlaceholder.frame
|
||||
|
||||
if textAlignment == .right {
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}else if textAlignment == .left{
|
||||
newFrame.origin.x = paddingX
|
||||
}else if textAlignment == .center{
|
||||
newFrame.origin.x = (bounds.width / 2.0) - (newFrame.size.width / 2.0)
|
||||
}else if textAlignment == .natural{
|
||||
|
||||
if UIView.userInterfaceLayoutDirection(for: semanticContentAttribute) == .rightToLeft{
|
||||
newFrame.origin.x = bounds.width - paddingX - newFrame.size.width
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
lblFloatPlaceholder.frame = newFrame
|
||||
}
|
||||
|
||||
fileprivate func hideErrorMessage(){
|
||||
lblError.text = ""
|
||||
lblError.isHidden = true
|
||||
lblError.frame = CGRect.zero
|
||||
invalidateIntrinsicContentSize()
|
||||
}
|
||||
|
||||
fileprivate func showFloatingLabel(_ animated:Bool) {
|
||||
|
||||
let animations:(()->()) = {
|
||||
self.lblFloatPlaceholder.alpha = 1.0
|
||||
self.lblFloatPlaceholder.frame = CGRect(x: self.lblFloatPlaceholder.frame.origin.x,
|
||||
y: self.paddingYFloatLabel,
|
||||
width: self.lblFloatPlaceholder.bounds.size.width,
|
||||
height: self.lblFloatPlaceholder.bounds.size.height)
|
||||
}
|
||||
|
||||
if animated && animateFloatPlaceholder {
|
||||
UIView.animate(withDuration: floatingLabelShowAnimationDuration,
|
||||
delay: 0.0,
|
||||
options: [.beginFromCurrentState,.curveEaseOut],
|
||||
animations: animations){ status in
|
||||
DispatchQueue.main.async {
|
||||
self.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}else{
|
||||
animations()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func hideFlotingLabel(_ animated:Bool) {
|
||||
|
||||
let animations:(()->()) = {
|
||||
self.lblFloatPlaceholder.alpha = 0.0
|
||||
self.lblFloatPlaceholder.frame = CGRect(x: self.lblFloatPlaceholder.frame.origin.x,
|
||||
y: self.lblFloatPlaceholder.font.lineHeight,
|
||||
width: self.lblFloatPlaceholder.bounds.size.width,
|
||||
height: self.lblFloatPlaceholder.bounds.size.height)
|
||||
}
|
||||
|
||||
if animated && animateFloatPlaceholder {
|
||||
UIView.animate(withDuration: floatingLabelShowAnimationDuration,
|
||||
delay: 0.0,
|
||||
options: [.beginFromCurrentState,.curveEaseOut],
|
||||
animations: animations){ status in
|
||||
DispatchQueue.main.async {
|
||||
self.layoutIfNeeded()
|
||||
}
|
||||
}
|
||||
}else{
|
||||
animations()
|
||||
}
|
||||
}
|
||||
|
||||
fileprivate func insetRectForEmptyBounds(rect:CGRect) -> CGRect{
|
||||
let newX = x
|
||||
guard showErrorLabel else { return CGRect(x: newX, y: 0, width: rect.width - newX - paddingX, height: rect.height) }
|
||||
|
||||
let topInset = (rect.size.height - lblError.bounds.size.height - paddingYErrorLabel - fontHeight) / 2.0
|
||||
let textY = topInset - ((rect.height - fontHeight) / 2.0)
|
||||
|
||||
return CGRect(x: newX, y: floor(textY), width: rect.size.width - newX - paddingX, height: rect.size.height)
|
||||
}
|
||||
|
||||
fileprivate func insetRectForBounds(rect:CGRect) -> CGRect {
|
||||
|
||||
guard let placeholderText = lblFloatPlaceholder.text,!placeholderText.isEmptyStr else {
|
||||
return insetRectForEmptyBounds(rect: rect)
|
||||
}
|
||||
|
||||
if floatingDisplayStatus == .never {
|
||||
return insetRectForEmptyBounds(rect: rect)
|
||||
}else{
|
||||
|
||||
if let text = text,text.isEmptyStr && floatingDisplayStatus == .defaults {
|
||||
return insetRectForEmptyBounds(rect: rect)
|
||||
}else{
|
||||
let topInset = paddingYFloatLabel + lblFloatPlaceholder.bounds.size.height + (paddingHeight / 2.0)
|
||||
let textOriginalY = (rect.height - fontHeight) / 2.0
|
||||
var textY = topInset - textOriginalY
|
||||
|
||||
if textY < 0 && !showErrorLabel { textY = topInset }
|
||||
let newX = x
|
||||
return CGRect(x: newX, y: ceil(textY), width: rect.size.width - newX - paddingX, height: rect.height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@objc fileprivate func textFieldTextChanged(){
|
||||
guard hideErrorWhenEditing && showErrorLabel else { return }
|
||||
showErrorLabel = false
|
||||
}
|
||||
|
||||
override public var intrinsicContentSize: CGSize{
|
||||
self.layoutIfNeeded()
|
||||
|
||||
let textFieldIntrinsicContentSize = super.intrinsicContentSize
|
||||
|
||||
if showErrorLabel {
|
||||
lblFloatPlaceholder.sizeToFit()
|
||||
return CGSize(width: textFieldIntrinsicContentSize.width,
|
||||
height: textFieldIntrinsicContentSize.height + paddingYFloatLabel + paddingYErrorLabel + lblFloatPlaceholder.bounds.size.height + lblError.bounds.size.height + paddingHeight)
|
||||
}else{
|
||||
return CGSize(width: textFieldIntrinsicContentSize.width,
|
||||
height: textFieldIntrinsicContentSize.height + paddingYFloatLabel + lblFloatPlaceholder.bounds.size.height + paddingHeight)
|
||||
}
|
||||
}
|
||||
|
||||
override public func textRect(forBounds bounds: CGRect) -> CGRect {
|
||||
let rect = super.textRect(forBounds: bounds)
|
||||
return insetRectForBounds(rect: rect)
|
||||
}
|
||||
|
||||
override public func editingRect(forBounds bounds: CGRect) -> CGRect {
|
||||
let rect = super.editingRect(forBounds: bounds)
|
||||
return insetRectForBounds(rect: rect)
|
||||
}
|
||||
|
||||
fileprivate func insetForSideView(forBounds bounds: CGRect) -> CGRect{
|
||||
var rect = bounds
|
||||
rect.origin.y = 0
|
||||
rect.size.height = dtLayerHeight
|
||||
return rect
|
||||
}
|
||||
|
||||
override public func leftViewRect(forBounds bounds: CGRect) -> CGRect {
|
||||
let rect = super.leftViewRect(forBounds: bounds)
|
||||
return insetForSideView(forBounds: rect)
|
||||
}
|
||||
|
||||
override public func rightViewRect(forBounds bounds: CGRect) -> CGRect {
|
||||
let rect = super.rightViewRect(forBounds: bounds)
|
||||
return insetForSideView(forBounds: rect)
|
||||
}
|
||||
|
||||
override public func clearButtonRect(forBounds bounds: CGRect) -> CGRect {
|
||||
var rect = super.clearButtonRect(forBounds: bounds)
|
||||
rect.origin.y = (dtLayerHeight - rect.size.height) / 2
|
||||
return rect
|
||||
}
|
||||
|
||||
override public func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
CATransaction.begin()
|
||||
CATransaction.setDisableActions(true)
|
||||
dtLayer.frame = CGRect(x: bounds.origin.x,
|
||||
y: bounds.origin.y,
|
||||
width: bounds.width,
|
||||
height: dtLayerHeight)
|
||||
let borderStype = dtborderStyle
|
||||
dtborderStyle = borderStype
|
||||
CATransaction.commit()
|
||||
|
||||
if showErrorLabel {
|
||||
|
||||
var lblErrorFrame = lblError.frame
|
||||
lblErrorFrame.origin.y = dtLayer.frame.origin.y + dtLayer.frame.size.height + paddingYErrorLabel
|
||||
lblError.frame = lblErrorFrame
|
||||
}
|
||||
|
||||
let floatingLabelSize = lblFloatPlaceholder.sizeThatFits(lblFloatPlaceholder.superview!.bounds.size)
|
||||
|
||||
lblFloatPlaceholder.frame = CGRect(x: x, y: lblFloatPlaceholder.frame.origin.y,
|
||||
width: floatingLabelSize.width,
|
||||
height: floatingLabelSize.height)
|
||||
|
||||
setErrorLabelAlignment()
|
||||
setFloatLabelAlignment()
|
||||
lblFloatPlaceholder.textColor = isFirstResponder ? floatPlaceholderActiveColor : floatPlaceholderColor
|
||||
|
||||
switch floatingDisplayStatus {
|
||||
case .never:
|
||||
hideFlotingLabel(isFirstResponder)
|
||||
case .always:
|
||||
showFloatingLabel(isFirstResponder)
|
||||
default:
|
||||
if let enteredText = text,!enteredText.isEmptyStr{
|
||||
showFloatingLabel(isFirstResponder)
|
||||
}else{
|
||||
hideFlotingLabel(isFirstResponder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,15 @@
|
||||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
@@ -35,4 +45,4 @@
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import DTTextField
|
||||
|
||||
class ViewController: UIViewController {
|
||||
|
||||
@@ -18,31 +17,30 @@ class ViewController: UIViewController {
|
||||
@IBOutlet weak var txtPassword: DTTextField!
|
||||
@IBOutlet weak var txtConfirmPassword: DTTextField!
|
||||
|
||||
let firstNameMessage = "First name is required."
|
||||
let lastNameMessage = "Last name is requried."
|
||||
let emailMessage = "Email is required."
|
||||
let passwordMessage = "Password is required."
|
||||
let confirmPasswordMessage = "Confirm password is required."
|
||||
let mismatchPasswordMessage = "Password and Confirm password are not matching."
|
||||
let firstNameMessage = NSLocalizedString("First name is required.", comment: "")
|
||||
let lastNameMessage = NSLocalizedString("Last name is required.", comment: "")
|
||||
let emailMessage = NSLocalizedString("Email is required.", comment: "")
|
||||
let passwordMessage = NSLocalizedString("Password is required.", comment: "")
|
||||
let confirmPasswordMessage = NSLocalizedString("Confirm password is required.", comment: "")
|
||||
let mismatchPasswordMessage = NSLocalizedString("Password and Confirm password are not matching.", comment: "")
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
title = "Registration"
|
||||
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
}
|
||||
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: .UIKeyboardWillShow, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: .UIKeyboardWillHide, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillShow(notification:)), name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(keyboardWillHide(notification:)), name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||
}
|
||||
|
||||
override func viewWillDisappear(_ animated: Bool) {
|
||||
super.viewWillDisappear(animated)
|
||||
NotificationCenter.default.removeObserver(self, name: .UIKeyboardWillShow, object: nil)
|
||||
NotificationCenter.default.removeObserver(self, name: .UIKeyboardWillHide, object: nil)
|
||||
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillShowNotification, object: nil)
|
||||
NotificationCenter.default.removeObserver(self, name: UIResponder.keyboardWillHideNotification, object: nil)
|
||||
}
|
||||
|
||||
override func didReceiveMemoryWarning() {
|
||||
@@ -56,31 +54,31 @@ class ViewController: UIViewController {
|
||||
|
||||
let alert = UIAlertController(title: "Congratulations", message: "Your registration is successful!!!", preferredStyle: .alert)
|
||||
alert.addAction(UIAlertAction(title: "OK", style: .cancel, handler: { (cancel) in
|
||||
|
||||
DispatchQueue.main.async {
|
||||
self.txtFirstName.text = ""
|
||||
self.txtLastName.text = ""
|
||||
self.txtEmail.text = ""
|
||||
self.txtConfirmPassword.text = ""
|
||||
self.txtPassword.text = ""
|
||||
}
|
||||
DispatchQueue.main.async { self.clearForm() }
|
||||
}))
|
||||
|
||||
present(alert, animated: true, completion: nil)
|
||||
|
||||
}
|
||||
|
||||
|
||||
func clearForm() {
|
||||
self.txtFirstName.text = ""
|
||||
self.txtLastName.text = ""
|
||||
self.txtEmail.text = ""
|
||||
self.txtConfirmPassword.text = ""
|
||||
self.txtPassword.text = ""
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: User Define Methods
|
||||
extension ViewController{
|
||||
|
||||
func keyboardWillShow(notification:Notification) {
|
||||
guard let keyboardHeight = (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue else { return }
|
||||
scrollView.contentInset = UIEdgeInsetsMake(0, 0, keyboardHeight.height, 0)
|
||||
@objc func keyboardWillShow(notification:Notification) {
|
||||
guard let keyboardHeight = (notification.userInfo?[UIResponder.keyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue else { return }
|
||||
scrollView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: keyboardHeight.height, right: 0)
|
||||
}
|
||||
|
||||
func keyboardWillHide(notification:Notification) {
|
||||
@objc func keyboardWillHide(notification:Notification) {
|
||||
scrollView.contentInset = .zero
|
||||
}
|
||||
|
||||
@@ -100,7 +98,7 @@ extension ViewController{
|
||||
txtEmail.showError(message: emailMessage)
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
guard !txtPassword.text!.isEmptyStr else {
|
||||
txtPassword.showError(message: passwordMessage)
|
||||
return false
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
|
||||
/* Class = "UILabel"; text = " Copyright (c) 2017 Dhaval Thanki. All rights reserved."; ObjectID = "8ie-xW-0ye"; */
|
||||
"8ie-xW-0ye.text" = " Copyright (c) 2017 Dhaval Thanki. All rights reserved.";
|
||||
|
||||
/* Class = "UILabel"; text = "DTTextField"; ObjectID = "kId-c2-rCX"; */
|
||||
"kId-c2-rCX.text" = "DTTextField";
|
||||
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
Arabic.strings
|
||||
DTTextField
|
||||
|
||||
Created by Dhaval Thanki on 16/03/18.
|
||||
Copyright © 2018 CocoaPods. All rights reserved.
|
||||
*/
|
||||
|
||||
"First name is required." = "الإسم الأول مطلوب.";
|
||||
"Last name is requried." = "الاسم الأخير مطلوب.";
|
||||
"Email is required." = "البريد الالكتروني مطلوب.";
|
||||
"Password is required." = "كلمة المرور مطلوبة.";
|
||||
"Confirm password is required." = "تأكيد كلمة المرور مطلوب.";
|
||||
"Password and Confirm password are not matching." = "كلمة المرور وتأكيد كلمة المرورغير متطابقين.";
|
||||
@@ -0,0 +1,18 @@
|
||||
|
||||
/* Class = "UITextField"; placeholder = "Password"; ObjectID = "63c-z6-Pat"; */
|
||||
"vOV-P3-5my.placeholder" = "كلمه السر";
|
||||
|
||||
/* Class = "UITextField"; placeholder = "Email"; ObjectID = "6gk-3f-Yz6"; */
|
||||
"G8b-0H-NOp.placeholder" = "البريد الإلكتروني";
|
||||
|
||||
/* Class = "UITextField"; placeholder = "First Name"; ObjectID = "LZk-sC-XSt"; */
|
||||
"LZk-sC-XSt.placeholder" = "الاسم الاول";
|
||||
|
||||
/* Class = "UIButton"; normalTitle = "Register"; ObjectID = "Vp4-XI-7k7"; */
|
||||
"Vp4-XI-7k7.normalTitle" = "تسجيل";
|
||||
|
||||
/* Class = "UITextField"; placeholder = "Last Name"; ObjectID = "ZMK-KE-9Cc"; */
|
||||
"ZMK-KE-9Cc.placeholder" = "الكنية";
|
||||
|
||||
/* Class = "UITextField"; placeholder = "Confirm Password"; ObjectID = "zBn-BA-f2Y"; */
|
||||
"oVW-xu-ETH.placeholder" = "تأكيد كلمة المرور";
|
||||
@@ -0,0 +1,9 @@
|
||||
/*
|
||||
Arabic.strings
|
||||
DTTextField
|
||||
|
||||
Created by Dhaval Thanki on 16/03/18.
|
||||
Copyright © 2018 CocoaPods. All rights reserved.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
use_frameworks!
|
||||
|
||||
target 'DTTextField_Example' do
|
||||
pod 'DTTextField'
|
||||
|
||||
target 'DTTextField_Tests' do
|
||||
inherit! :search_paths
|
||||
|
||||
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1,10 @@
|
||||
# DTTextField
|
||||
|
||||
[](https://github.com/iDhaval/DTTextField/releases/tag/0.2.3)
|
||||
[](https://github.com/iDhaval/DTTextField/releases/tag/0.2.4)
|
||||
[](https://github.com/iDhaval/DTTextField/blob/master/LICENSE)
|
||||
[](https://github.com/matteocrippa/awesome-swift)
|
||||
[](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/)
|
||||

|
||||
[](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/)
|
||||

|
||||
|
||||

|
||||
|
||||
@@ -16,12 +16,12 @@ Floating placeholder inspired from [JVFloatLabeledTextField](https://github.com/
|
||||
|
||||
## Example
|
||||
|
||||
To run the example project, clone the repo, and run `pod install` from the Example directory first.
|
||||
Clone the repo and run the example project from the Example directory.
|
||||
|
||||
## Requirements
|
||||
|
||||
* Xcode 8.0
|
||||
* Swift 3.0
|
||||
* Xcode 11.0+
|
||||
* Swift 5.0+
|
||||
|
||||
## Installation
|
||||
|
||||
@@ -54,13 +54,15 @@ pod 'DTTextField'
|
||||
| hideErrorWhenEditing | Bool | hide error label when typing |
|
||||
| floatingDisplayStatus | enum | maintain display status always, never, defaults |
|
||||
|
||||
|
||||
### Important Properties
|
||||
|
||||
| Property name | Type | Remark |
|
||||
| ------------- |------------- | ----- |
|
||||
| dtLayer | CALayer | If you want to formate DTTextField than use dtLayer property instead of layer |
|
||||
| dtLayer | CALayer | If you want to formate DTTextField than use dtLayer property instead of layer (e.g. background color) |
|
||||
| borderColor | UIColor | Change border color of DTTextField |
|
||||
| canShowBorder | Bool | Toggle border of DTTextField |
|
||||
| dtborderStyle | enum | none, rounded , sqare |
|
||||
|
||||
## Methods
|
||||
|
||||
@@ -69,6 +71,10 @@ pod 'DTTextField'
|
||||
| showError | to show error message |
|
||||
| hideError | to hide error message |
|
||||
|
||||
## Note
|
||||
|
||||
Don't give height constraint to DTTextField otherwise it won't work properly.
|
||||
|
||||
## TODO
|
||||
* Add inbuilt validation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user