4 Commits

Author SHA1 Message Date
Dhaval Thanki fa80dfcc2a - Code optimized 2017-04-13 15:06:07 +05:30
Dhaval Thanki f60823d275 Update README.md 2017-04-12 17:51:15 +05:30
Dhaval Thanki 9623689d46 Update README.md 2017-04-12 17:50:26 +05:30
Dhaval Thanki 9b9aed68f2 - V 0.2.3 published 2017-04-12 17:46:31 +05:30
3 changed files with 28 additions and 14 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
Pod::Spec.new do |s|
s.name = 'DTTextField'
s.version = '0.2.2'
s.version = '0.2.3'
s.summary = 'DTTextField is UITextField library.'
s.description = <<-DESC
+16 -7
View File
@@ -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 { 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 {
+11 -6
View File
@@ -1,9 +1,9 @@
# DTTextField
![Version](https://img.shields.io/badge/Pod-V0.2.2-green.svg)
![License](https://img.shields.io/github/license/mashape/apistatus.svg)
[![Version](https://img.shields.io/badge/Pod-V0.2.3-green.svg)](https://github.com/iDhaval/DTTextField/releases/tag/0.2.3)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/iDhaval/DTTextField/blob/master/LICENSE)
[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/matteocrippa/awesome-swift)
![Platform](https://img.shields.io/badge/Language-Swift_3.0-orange.svg)
[![Platform](https://img.shields.io/badge/Language-Swift_3.0-orange.svg)](https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/)
![Xcode](https://img.shields.io/badge/Xcode-8.0-blue.svg)
![Demo](https://github.com/iDhaval/DTTextField/blob/master/DTTextField.gif?raw=true)
@@ -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