I'm using the below method to set my textView.typingAttributes foreground color to red in Swift 3.
textView.typingAttributes[NSForegroundColorAttributeName] = UIColor.red
Now, that I've migrated to Swift 4 its showing error, I tried like below but its still showing error. Whats the correct way to set it?
textView.typingAttributes[NSAttributedStringKey.foregroundColor] = UIColor.red
Try this:
textView.typingAttributes[NSAttributedStringKey.foregroundColor.rawValue] =
UIColor.red
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With