The NSText​Field​Cell class adds to the text display capabilities of the NSCell class by allowing you to set the color of both the text and its background. You can also specify whether the cell draws its background at all.


All of the methods declared by this class are also declared by the NSText​Field class, which uses NSText​Field​Cell objects to draw and edit text. These NSText​Field cover methods call the corresponding NSText​Field​Cell methods.

Placeholder strings, set using the placeholder​String or placeholder​Attributed​String property, now appear in the text field cell if the actual string is nil or @"". They are drawn in grey on the cell and are not archived in the “pre-10.2” nib format.

Designated Initializers

When subclassing NSText​Field​Cell you must implement all of the designated initializers. Those methods are: init(coder:​), init(text​Cell:​), and init(image​Cell:​).


Setting the Text Color

var text​Color:​ NSColor?

The color used to draw the cell’s text.

Setting the Bezel Style

var bezel​Style:​ NSText​Field​Bezel​Style

The bezel style to use when drawing the text field.

Controlling the Background

var background​Color:​ NSColor?

The color of the cell’s background.

var draws​Background:​ Bool

A Boolean value indicating whether the cell draws its background color.

Managing the Field Editor

func set​Up​Field​Editor​Attributes(NSText)

Sets up the field editor. You never invoke this method directly; by overriding it, however, you can customize the field editor.

func set​Wants​Notification​For​Marked​Text(Bool)

Directs the cell’s associated field editor to post text change notifications.

Managing Placeholder Strings

var placeholder​String:​ String?

The placeholder text for the cell, specified as a plain text string.

var placeholder​Attributed​String:​ NSAttributed​String?

The placeholder text for the cell, specified as an attributed string.

Accessing Input Source Locales

var allowed​Input​Source​Locales:​ [String]?

An array of locale identifiers representing the allowed input sources when the text field has the keyboard focus.



Specify the bezel style of the text field cell.


Inherits From