这个形容或许没有表述清楚,大概的意思是:label显示的时候,是一个字一个字逐渐显示出来的,给人一种对话的感觉。
utfstrlen = function(str) local len = #str; local left = len; local cnt = 0; local arr={0,0xc0,0xe0,0xf0,0xf8,0xfc}; while left ~= 0 do local tmp=string.byte(str,-left); local i=#arr; while arr[i] do if tmp>=arr[i] then left=left-i; break; end; i=i-1; end; cnt=cnt+1; end; return cnt; end;
local lenNowDec = utfstrlen(nowDec); local lenDes = utfstrlen(desc);
if lenNowDec < lenDec then --截取,重新设置 local str =utf8sub(desc,lenNowDec + 1); self.captionLabel:setString(str); end;
utf8sub = function(str, startChar, numChars) local startIndex = 1; while startChar > 1 do local char = string.byte(str, startIndex); startIndex = startIndex + DataSheetMgr.chsize(char); startChar = startChar - 1; end local currentIndex = startIndex; while numChars > 0 and currentIndex <= #str do local char = string.byte(str, currentIndex); currentIndex = currentIndex + DataSheetMgr.chsize(char); numChars = numChars -1; end; return str:sub(startIndex, currentIndex - 1); end;
原文:http://blog.csdn.net/zh379835552/article/details/41049001