Cocos Creator iOS13 深色模式导致EditBox白色字体看不到

  • iOS 升级到13后,新出了一个深色模式。然后用Cocos creator开发的软件,用到EditBox输入时,字体的颜色为白色,这样就基本上看不清了。解决办法在ios工程下修改二行代码
  • 找到文件jsb-default/frameworks/cocos2d-x/cocos/ui/edit-box/EditBox-ios.mm,找到二处initTextField中添加g_textField.textColor = [UIColor blackColor]
void initTextField(const CGRect& rect, const cocos2d::EditBox::ShowInfo& showInfo)
{
    if (! g_textField)
    {
        g_textField = [[UITextField alloc] initWithFrame:rect];
        [g_textField setBorderStyle:UITextBorderStyleLine];
        // 添加textColor值为黑色
        g_textField.textColor = [UIColor blackColor];

        g_textField.backgroundColor = [UIColor whiteColor];

        ...
    }
}

void initTextView(const CGRect& viewRect, const CGRect& btnRect, const cocos2d::EditBox::ShowInfo& showInfo)
{
    if (!g_textView)
    {
        g_textView = [[UITextView alloc] initWithFrame:btnRect];

        // 添加textColor值为黑色
        g_textView.textColor = [UIColor blackColor]

        // 这里要添加背景色为白色,不然多行输入会有问题
        g_textView.backgroundColor= [UIColor whiteColor]

        g_textViewDelegate = [[TextViewDelegate alloc] init];
        g_textView.delegate = g_textViewDelegate;

        ...
    }
}
0%