Simple Animation TextField Swift 4
This is how to create animation with cocoapod library, ok I will give an example with library AnimatedTextInput .
Use cocoapods to install this custom control in your project.
pod 'AnimatedTextInput'
how to use it is quite easy, see the coding below
import UIKit
import AnimatedTextInput
class TextInputViewController: UIViewController {
@IBOutlet weak var labelT: UILabel!
@IBOutlet weak var textAnimate: AnimatedTextInput!
override func viewDidLoad() {
super.viewDidLoad()
textAnimate.placeHolderText = "Paswword"
textAnimate.style = CustomTextInputStyle()
textAnimate.type = .password(toggleable: true)
}
}
struct CustomTextInputStyle: AnimatedTextInputStyle {
let placeholderInactiveColor = UIColor.gray
let activeColor = #colorLiteral(red: 0.4588235294, green: 0.7176470588, blue: 0.1803921569, alpha: 1)
let inactiveColor = UIColor.gray.withAlphaComponent(0.3)
let lineInactiveColor = UIColor.gray.withAlphaComponent(0.3)
let lineActiveColor = UIColor.gray.withAlphaComponent(0.3)
let lineHeight: CGFloat = 1
let errorColor = UIColor.red
let textInputFont = UIFont.systemFont(ofSize: 14)
let textInputFontColor = UIColor.black
let placeholderMinFontSize: CGFloat = 12
let counterLabelFont: UIFont? = UIFont.systemFont(ofSize: 12)
let leftMargin: CGFloat = 0
let topMargin: CGFloat = 20
let rightMargin: CGFloat = 0
let bottomMargin: CGFloat = 10
let yHintPositionOffset: CGFloat = 7
let yPlaceholderPositionOffset: CGFloat = 0
public let textAttributes: [String: Any]? = nil
}
No comments: