 
 import UIKit
 
+open class DisplayLinkHelper {
+
+    private let displayLink: CADisplayLink?
+    private(set) var timeInterval: CFTimeInterval?
+
+    private let target: Any
+    private let selector: Selector
+
+    init(target: Any, selector: Selector) {
+        self.target = target
+        self.selector = selector
+
+        displayLink = CADisplayLink(target: target, selector: selector)
+        displayLink?.add(to: .main, forMode: .commonModes)
+    }
+
+    func start() {
+        timeInterval = CFAbsoluteTimeGetCurrent()
+        displayLink?.isPaused = false
+    }
+
+    func stop() {
+        timeInterval = nil
+        displayLink?.isPaused = true
+    }
+}
+
 /**
  A beautiful and flexible textfield implementation with support for title label, error message and placeholder.
  */

        return hasText || hasErrorMessage || _titleVisible
    }

    fileprivate func updateTitleVisibility(_ animated: Bool = false, completion: ((_ completed: Bool) -> Void)? = nil) {
        let alpha: CGFloat = isTitleVisible() ? 1.0 : 0.0
        let frame: CGRect = titleLabelRectForBounds(bounds, editing: isTitleVisible())
        let updateBlock = { () -> Void in
            self.titleLabel.alpha = alpha
            self.titleLabel.frame = frame
        }
        if animated {
            let animationOptions: UIViewAnimationOptions = .curveEaseOut
            let duration = isTitleVisible() ? titleFadeInDuration : titleFadeOutDuration
            UIView.animate(withDuration: duration, delay: 0, options: animationOptions, animations: { () -> Void in
                updateBlock()
                }, completion: completion)
        } else {
            updateBlock()
            completion?(true)
        }
    }

           updateTextAligment()
        }
    }

    private lazy var displayLink = DisplayLinkHelper(target: self, selector: #selector(setupTitleVisibility))

    fileprivate func updateTextAligment() {
        if isLTRLanguage {
