# CCTextField Class Reference

Inherits from | CCControl : CCNode : CCResponder : NSObject
Conforms to | UITextFieldDelegate
Declared in | CCTextField.h

## Overview

The CCTextField is used for editing text by encapsulating a native text field (NSTextField on Mac and UITextField on iOS). An action callback will be sent when the text finishes editing or if the return key is pressed.

Warning: The native text field is only translated, no other transformations are applied. The text field may not be displayed correctly if rotated or scaled.

## Tasks

- `+ textFieldWithSpriteFrame:`
- `– initWithSpriteFrame:`
- `textField` property
- `backgroundSpriteFrame` property
- `fontSize` property
- `padding` property
- `string` property

## Properties

### backgroundSpriteFrame

The sprite frame used to render the text field’s background.

`@property (nonatomic, strong) CCSpriteFrame *backgroundSpriteFrame`

#### Declared In

`CCTextField.h`

### fontSize

The font size of the text field, defined in the unit specified by the heightUnit component of the contentSizeType.

`@property (nonatomic, assign) float fontSize`

#### Declared In

`CCTextField.h`

### padding

Padding from the edge of the text field’s background to the native text field component.

`@property (nonatomic, assign) float padding`

#### Declared In

`CCTextField.h`

### string

The text displayed by the text field.

`@property (nonatomic, strong) NSString *string`

#### Declared In

`CCTextField.h`

### textField

iOS: UITextField used by the CCTextField.

`@property (nonatomic, readonly) UITextField *textField`

#### Declared In

`CCTextField.h`

## Class Methods

### textFieldWithSpriteFrame:

Creates a new text field with the specified sprite frame used as its background.

`+ (id)textFieldWithSpriteFrame:(CCSpriteFrame *)frame`

#### Parameters

frame

  Sprite frame to use as the text fields background.

#### Return Value

Returns a new text field.

#### Declared In

`CCTextField.h`

## Instance Methods

### initWithSpriteFrame:

Initializes a text field with the specified sprite frame used as its background.

`- (id)initWithSpriteFrame:(CCSpriteFrame *)frame`

#### Parameters

frame

  Sprite frame to use as the text fields background.

#### Return Value

Returns a new text field.

#### Declared In

`CCTextField.h`