cocos2d JS 创建实现换行功能的聊天文本 testLable
2017-07-28 05:44 罗任德 阅读(979) 评论(0) 编辑 收藏 举报-- 创建实现换行功能的文本
function LoadLabelHeroIntroduce(objLabelContent) //传入文本
---------------------------------
local tLabel = LG.Label:create()
-- 实现换行功能 tLabel:ignoreContentAdaptWithSize(false)
tLabel:setText(objLabelContent) // 文本赋值
local tSize = tLabel:getContentSize() // 获取 size
local tmp_width = tSize.width
local end_height = (tmp_width / 180 +1)* (tSize.height) // 计算高度
tLabel:setSize(Global_CCSize(180,end_height)) // 设置side
return tLabel
--------------------------------- end