--[[
@desc: 创建以特殊字符隔开并修改文本颜色的富文本
--@str:完整字符串
--@fontSize:字体大小
--@tbColor: {[1] = 普通字体颜色, [2] = 标记字体颜色}
--@iMaxWidth: label最大长度
@return: node,iHeight
]]
function Tool:CreateColorText(str, iFontSize, tbColor, iMaxWidth)
local pNode = cc.Node:create()
local allStr = {
}
local r = {
}
if (str == nil) then
return nil
end
for word in string.gmatch(str, "%P+[%s|%p]") do
if string.find(word, " ") then
for sub in string.gmatch(word, "%S+%s*") do
table.insert(allStr, sub)
end
else
table.insert(allStr,
lua按照标点符号或空格分割单词
于 2022-11-29 20:01:50 首次发布