Colors cocos2d/kobold2d中的文本字段未显示颜色
我需要创建一个文本字段,在这里我的游戏中的玩家可以输入他们的名字以获得高分。我回答了这个问题:,并成功地用键盘创建了一个文本字段。但是,文本字段的文本是白色的,背景色也是白色的,所以我看不到文本字段,只有键盘 代码如下: appdelegate.hColors cocos2d/kobold2d中的文本字段未显示颜色,colors,cocos2d-iphone,textfield,kobold2d,Colors,Cocos2d Iphone,Textfield,Kobold2d,我需要创建一个文本字段,在这里我的游戏中的玩家可以输入他们的名字以获得高分。我回答了这个问题:,并成功地用键盘创建了一个文本字段。但是,文本字段的文本是白色的,背景色也是白色的,所以我看不到文本字段,只有键盘 代码如下: appdelegate.h #import "KKAppDelegate.h" @interface AppDelegate : KKAppDelegate { UITextField *nameTextField; } -(void)specifyPlayerNam
#import "KKAppDelegate.h"
@interface AppDelegate : KKAppDelegate
{
UITextField *nameTextField;
}
-(void)specifyPlayerName;
@end
appdelegate.m
@implementation AppDelegate
-(void) initializationComplete
{
#ifdef KK_ARC_ENABLED
CCLOG(@"ARC is enabled");
#else
CCLOG(@"ARC is either not available or not enabled");
#endif
}
- (void)specifyPlayerName
{
NSLog(@"called");
nameTextField = [[UITextField alloc] initWithFrame:CGRectMake(60, 165, 200, 90)];
[nameTextField setDelegate:self];
[nameTextField setText:@""];
[nameTextField setTextColor: [UIColor colorWithRed:0 green:0 blue:0 alpha:1.0]];
[[[[CCDirector sharedDirector] openGLView] window] addSubview:nameTextField];
[nameTextField becomeFirstResponder];
}
- (BOOL)textFieldShouldReturn:(UITextField*)textField {
//Terminate editing
[textField resignFirstResponder];
return YES;
}
- (void)textFieldDidEndEditing:(UITextField*)textField {
if (textField==nameTextField) {
[nameTextField endEditing:YES];
// here is where you should do something with the data they entered
GameData* data = [GameData sharedData];
data.playerName = nameTextField.text;
NSLog(@"entered: %@", data.playerName);
}
}
正在从另一个类/按钮调用该方法
[[[UIApplication sharedApplication] delegate]performSelector:@selector(specifyPlayerName)];
我试图设置文本字段的颜色,但它仍然显示为全白色。任何帮助都将不胜感激 我发现文本字段隐藏在另一个视图后面,所以
[[[CCDirector sharedDirector] openGLView] addSubview:nameTextField];
而不是
[[[[CCDirector sharedDirector] openGLView] window] addSubview:nameTextField];
文本字段颜色默认为黑白相间 我发现文本字段隐藏在另一个视图后面,所以
[[[CCDirector sharedDirector] openGLView] addSubview:nameTextField];
而不是
[[[[CCDirector sharedDirector] openGLView] window] addSubview:nameTextField];
文本字段颜色默认为黑白相间