cocos2dx-Lua中Label文本超过特定长度使用...代替
开发环境:cocos2dx 3.17
开发语言:lua
我们在开发过程中,经常会遇到字符串过长,显示的时候超出范围,我们可以用...
来代替字符串后面的内容。
代码:
function getStrByLen(str, len)
if str == nil or len == nil then
return
end
local limitStr = str
if(string.len(limitStr) > len) then
local sName = SubUTF8String(limitStr , len)
return sName.."..."
end
return limitStr
end
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 三尺青锋!
评论