Guest User

Untitled

a guest
Mar 4th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.91 KB | None | 0 0
  1.   private var isPlaceholderActive: Bool {
  2.     return textView.text == FeedbackView.feedbackPlaceholderText && textView.textColor == FeedbackView.feedbackPlaceholderTextColor
  3.   }
  4.  
  5.   public func textViewDidBeginEditing(_ textView: UITextView) {
  6.     if (isPlaceholderActive) {
  7.       textView.text =  ""
  8.       textView.textColor = UIColor.black
  9.     }
  10.   }
  11.  
  12.   public func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
  13.     if (text == "\n") {
  14.       textView.resignFirstResponder()
  15.       if(!isPlaceholderActive) {
  16.         forTextViewActionHiddenButton.sendActions(for: .touchUpInside)
  17.       }
  18.     }
  19.     return true
  20.   }
  21.  
  22.   public func textViewDidEndEditing(_ textView: UITextView) {
  23.     if (textView.text.isEmpty) {
  24.       textView.text = FeedbackView.feedbackPlaceholderText
  25.       textView.textColor = FeedbackView.feedbackPlaceholderTextColor
  26.     }
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment