iOS swift text background color uitextview

1.8k Views Asked by At

I am trying to write code for a button that will change the background color of text selected by a user in a UITextView.

This is how I implemented the Bold formatting button:

@IBAction func boldButton() {
    textView.toggleBoldface(self)
}

But I don't know how to do something analogous for changing the background color of the selected text. Example code would be great! Thx!

1

There are 1 best solutions below

5
On

You can set the tintColor property of the UITextView to accomplish this.