mcmar
mcmar

Reputation: 450

Is it possible to change Color on a per line basis in NSTextField?

I have a Swift Mac OS X project with a NSTextField where I display multiple lines of text. I can change the color of all the text in the text field

    searchResult_field.stringValue = result
    searchResult_field.textColor = NSColor.redColor()

But I'd like to be able have some lines the default color and others a different color.

Upvotes: 1

Views: 182

Answers (1)

Or Ron
Or Ron

Reputation: 2343

You can use NSAttributedString to color each range of the string in a different color.

Upvotes: 1

Related Questions