1

I want to ask how to set CCTextField placeholder and color. I know it is easy to create a text field on spritebuilder, but it cannot set the text color and placeholder like UITextField.

HipSze
  • 19
  • 4

1 Answers1

1
yourTextField.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Placeholder String" attributes:@{NSForegroundColorAttributeName: [UIColor grayColor]}];

Same thing if you have to use the text too. Use the property .attributedText

When I had this problem I had to change a Cocos2d file:

cocos2d-ui/Platform/iOS/CCPlatformTextFieldIOS.m

- (id)nativeTextField
{
    return _textField;
}

I would recommend just trying to use attributed string before changing cocos2d files. I'm using cocos2d v3 and xcode 6.1.1

Asdrubal
  • 2,421
  • 4
  • 29
  • 37