0

Hi I'm new to iOS app development. I am implemented an UITextview to add multiple address separated by comma I need to apply a style bubble when user separates the email by pressing comma or space or done button (in the keyboard.) reference screen shot from android

I am executing an email array same as below

func executeEmailArray(){
        self.emailString = self.emailTF.text ?? ""
        self.emailArray = emailString.components(separatedBy: ",")
        print("emailArray \(self.emailArray)")
    }

I formatted the uiTextView as below by using an extension

extension NewShoppingListVC: UITextViewDelegate {
func textViewDidChangeSelection(_ textView: UITextView) {
    // Moves cursor to start when tapped on textView with placeholder
    if emailTF.text == placeholder {
        emailTF.selectedRange = start
    }
}
func textViewDidChange(_ textView: UITextView) {
    // Manages state of text when changed
    if emailTF.text.isEmpty {
        emailTF.text = placeholder
        emailTF.textColor = .lightGray
    } else if emailTF.text != placeholder {
        emailTF.textColor = .black
    }
}
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
    // Called when you're trying to enter a character (to replace the placeholder)
    if emailTF.text == placeholder {
        emailTF.text = ""
    }
    return true
}

}

Please add some codes to explain me how to apply the textbubbles as in the image

Community
  • 1
  • 1
Swiosift
  • 143
  • 2
  • 14
  • https://stackoverflow.com/a/34050391/4637057 – Vincent Joy Jun 01 '20 at 10:43
  • https://stackoverflow.com/questions/16362407/nsattributedstring-background-color-and-rounded-corners – Larme Jun 01 '20 at 14:13
  • Does this answer your question? [NSAttributedString background color and rounded corners](https://stackoverflow.com/questions/16362407/nsattributedstring-background-color-and-rounded-corners) – Roman Podymov Jun 01 '20 at 17:30

0 Answers0