简体   繁体   English

CCLabelTTF :: setString在字符串的开头和结尾不接受空格

[英]CCLabelTTF::setString not accepting white space at start and end of string

I'm trying to set value of a label in cocos2d-x. 我正在尝试在cocos2d-x中设置标签的值。 It's not showing spaces if I add them on start or end of string, like 如果我在字符串的开头或结尾添加空格,则不会显示空格,例如

label->setString("10 10");

working correctly. 工作正常。 But if I use 但是如果我用

label->setString(" 10");
label->setString("10 ");

it only show "10" , spaces are trimmed. 它仅显示“ 10”,并修剪了空格。

I figure out the problem, label->setString() function is ok. 我发现了问题, label->setString()函数正常。 Problem is with label->getContentSize().width , it does not include white spaces at start and end of string while calculating width of label(this problem occurs while working in windows phone 8.1).And labels were overwriting in my case because of incorrect positioning. 问题是label->getContentSize().width ,它在计算标签宽度时不包括字符串开头和结尾的空格(在Windows Phone 8.1中工作时会发生此问题)。在我的情况下,标签被覆盖是因为定位不正确。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM