Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a6cd5efbb | |||
| 7c1d6bc4ae | |||
| 134ea16381 | |||
| fa80dfcc2a | |||
| f60823d275 | |||
| 9623689d46 | |||
| 9b9aed68f2 |
+1
-1
@@ -9,7 +9,7 @@
|
||||
Pod::Spec.new do |s|
|
||||
|
||||
s.name = 'DTTextField'
|
||||
s.version = '0.2.2'
|
||||
s.version = '0.2.4'
|
||||
s.summary = 'DTTextField is UITextField library.'
|
||||
|
||||
s.description = <<-DESC
|
||||
|
||||
@@ -85,8 +85,11 @@ public class DTTextField: UITextField {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -271,10 +274,10 @@ public class DTTextField: UITextField {
|
||||
|
||||
guard showErrorLabel else { return CGRect(x: x, y: 0, width: rect.width - paddingX, height: rect.height) }
|
||||
|
||||
let topInset = (rect.size.height - lblError.bounds.size.height - paddingYErrorLabel - ceil(font!.lineHeight)) / 2.0
|
||||
let textY = ((rect.height - ceil(font!.lineHeight)) / 2.0) - topInset
|
||||
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: -ceil(textY), width: rect.size.width - paddingX, height: rect.size.height)
|
||||
return CGRect(x: x, y: floor(textY), width: rect.size.width - paddingX, height: rect.size.height)
|
||||
}
|
||||
|
||||
fileprivate func insetRectForBounds(rect:CGRect) -> CGRect {
|
||||
@@ -289,9 +292,12 @@ public class DTTextField: UITextField {
|
||||
return insetRectForEmptyBounds(rect: rect)
|
||||
}else{
|
||||
let topInset = paddingYFloatLabel + lblFloatPlaceholder.bounds.size.height + (paddingHeight / 2.0)
|
||||
let textOriginalY = (rect.height - font!.lineHeight) / 2.0
|
||||
let textY = textOriginalY - topInset
|
||||
return CGRect(x: x, y: -ceil(textY), width: rect.size.width - paddingX, height: rect.size.height)
|
||||
let textOriginalY = (rect.height - fontHeight) / 2.0
|
||||
var textY = topInset - textOriginalY
|
||||
|
||||
if textY < 0 && !showErrorLabel { textY = topInset }
|
||||
|
||||
return CGRect(x: x, y: ceil(textY), width: rect.size.width - paddingX, height: rect.height)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -354,10 +360,13 @@ public class DTTextField: UITextField {
|
||||
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)
|
||||
CATransaction.commit()
|
||||
|
||||
if showErrorLabel {
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
# DTTextField
|
||||
|
||||

|
||||

|
||||
[](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/)
|
||||

|
||||
|
||||

|
||||
@@ -44,7 +44,6 @@ pod 'DTTextField'
|
||||
| ------------- |------------- | ----- |
|
||||
| errorMessage | String | Add your error message to this property|
|
||||
| errorFont | UIFont | Change font of error text |
|
||||
| showError | Bool | Use to toggle error message|
|
||||
| paddingYErrorLabel | CGFloat | Error text top padding |
|
||||
| floatPlaceholderColor | UIColor | To change float placeholder color |
|
||||
| floatPlaceholderActiveColor | UIColor | To change float placeholder color while TextField is active(First responder)|
|
||||
@@ -53,17 +52,23 @@ pod 'DTTextField'
|
||||
| placeholderColor | UIColor | change placeholder color |
|
||||
| animateFloatPlaceholder | Bool | animate float placeholder label |
|
||||
| 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 |
|
||||
| borderColor | UIColor | Change border color of DTTextField |
|
||||
| canShowBorder | Bool | Toggle border of DTTextField |
|
||||
|
||||
## Methods
|
||||
|
||||
| Method Name | Remark |
|
||||
| ------------|--------|
|
||||
| showError | to show error message |
|
||||
| hideError | to hide error message |
|
||||
|
||||
## TODO
|
||||
* Add inbuilt validation
|
||||
|
||||
|
||||
Reference in New Issue
Block a user