Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting textView.typingAttributes foreground color in Swift 4

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
like image 445
Francis F Avatar asked Jul 29 '17 15:07

Francis F


1 Answers

Try this:

textView.typingAttributes[NSAttributedStringKey.foregroundColor.rawValue] =
    UIColor.red
like image 58
matt Avatar answered Nov 15 '22 06:11

matt