我想问一下如何设置CCTextField占位符和颜色。 我知道在spritebuilder上创建文本字段很容易,但它不能像UITextField那样设置文本颜色和占位符。
答案 0 :(得分:1)
yourTextField.textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"Placeholder String" attributes:@{NSForegroundColorAttributeName: [UIColor grayColor]}];
如果你也必须使用文本也一样。使用属性.attributedText
当我遇到此问题时,我不得不更改Cocos2d文件:
的cocos2d-UI /平台/式IO / CCPlatformTextFieldIOS.m
- (id)nativeTextField
{
return _textField;
}
我建议在更改cocos2d文件之前尝试使用属性字符串。我正在使用cocos2d v3和xcode 6.1.1